Skip to content

jest tests are failing when running within a Yarn workspace #4021

Closed
@rolandjitsu

Description

@rolandjitsu

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes.

Which terms did you search for in User Guide?

yarn workspaces, jest fails, yarn jest, jest env, dispose is not a function, jest typeError environment, etc.

Environment

  1. node -v: 894
  2. npm -v: 5.6.0
  3. yarn --version (if you use Yarn): 1.3.2
  4. npm ls react-scripts (if you haven’t ejected):
# react-scripts
sauron@0.4.0 /Users/agroza/Projects/bbp/sauron
└── (empty)

# react-scripts-ts
sauron@0.4.0 /Users/agroza/Projects/bbp/sauron
└── react-scripts-ts@2.13.0  extraneous

Then, specify:

  1. Operating system: Mac OS X Sierra 10.12
  2. Browser and version (if relevant):

Steps to Reproduce

  1. Clone cra-workspaces
  2. Run yarn install at root
  3. Navigate to apps/cra and run yarn test
  4. Navigate to packages/package-a/packages/package-b and run yarn run test:cov

Expected Behavior

Tests should run without errors.

Actual Behavior

Some tests are throwing:

 FAIL  src/foo.spec.ts
  ● Test suite failed to run

    TypeError: environment.setup is not a function

      at ../../node_modules/jest-runner/build/run_test.js:112:23

Reproducible Demo

See cra-workspaces repo for an example of setup that has this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions