在从package.json安装了带有yarn的包之后,然后启动yarn test,我得到了以下错误:
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.当我用npm i运行安装软件包时,然后用yarn test运行测试,测试就会通过。
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. 问题是,当我用yarn或npm安装软件包时,有什么不同。
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"
}
}发布于 2018-04-12 13:37:39
试着:
如果您的
react-scripts和jest都在package.json中,请从package.json中删除jest。然后删除package-lock.json、yarn.lock和node_modules。然后运行npm install(如果您使用它,则运行yarn)。
因此,如果您使用纱线,运行yarn install而不是npm install,然后再试一次。
https://stackoverflow.com/questions/49797293
复制相似问题