Why does this work with npm but no yarn?

After installing packages from package.jsonc yarn, then run yarn testI have the following error:

FAIL  src/Dashboard/AppBar/Tests/AppBar.test.js
   Test suite failed to run

    TypeError: environment.setup is not a function

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

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        0.478s
Ran all test suites related to changed files.

When I worked with npm ito install the packages, then run the test using yarn test, the test will pass.

 PASS  src/Dashboard/AppBar/Tests/AppBar.test.js
   renders (92ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        1.452s, estimated 2s
Ran all test suites related to changed files.

Watch Usage: Press w to show more.  

The question is what it is when I install my packages using yarnor npm.

The contents of package.json:

{
  "name": "sample",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "bs-axios": "^0.0.34",
    "material-ui": "^1.0.0-beta.41",
    "react": "^16.3.1",
    "react-dom": "^16.3.1",
    "react-scripts": "1.1.4",
    "reason-react": "^0.3.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
    "mlbuild": "bsb -make-world",
    "mlstart": "bsb -make-world -w",
    "mlclean": "bsb -clean-world"
  },
  "devDependencies": {
    "bs-platform": "^2.2.3",
    "enzyme": "^3.3.0",
    "enzyme-adapter-react-16": "^1.1.1",
    "jest": "^22.4.3"
  }
}
+4
source share
1 answer

Try:

If you have react-scriptsand jestin package.json, remove jestfrom it. Then delete package-lock.json, yarn.lockand node_modules. Then run npm install(or yarnif you use it).

, , yarn install npm install .

: https://github.com/facebook/jest/issues/5119

0

Source: https://habr.com/ru/post/1696109/


All Articles