Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #338
Closed
Open
Issue created Aug 03, 2016 by Administrator@rootContributor

Decide on Jest's default environment

Created by: cpojer

Jest ships with jsdom by default. With the test renderer we don't need jsdom so I recommend people to use the node environment, also in CRA: https://github.com/facebookincubator/create-react-app/blob/master/scripts/utils/create-jest-config.js#L22

However, I expect people would like to continue using enzyme until they are fully bought into snapshot testing and until the test renderer supports all the APIs to put enzyme itself (or a compatible API) on top of the test renderer.

Here are the possible solutions:

  • Remove the testEnvironment config I linked to above. The only downside is that Jest's startup increases by 500ms because jsdom takes 500ms to require. (simply measure require('jsdom');) . This is the easiest fix.
  • Encourage people to install and load jsdom themselves: It's basically const window = require('jsdom').jsdom(...).defaultView;

I don't have strong feelings either way. Personally I'd like to get into a place where jsdom is available but not the default in Jest (maybe with a @jest-env jsdom directive in the header; we haven't finalized our ideas yet).

For CRA, given that people predominantly write web apps, it likely makes sense to take this performance hit and go with option one. It's a bit slower but the saner no-config default.

Assignee
Assign to
Time tracking