Reputation: 747
Running a few tests for react js using Jest and Enzyme but one of the files keeps breaking. Using Jest and Enzyme
I already cleared the cache, but I keep getting the following :
NPM ERR ! Test failed and worker process has quit unexpectedly!
Most likely this is an initialization error
Here is part of the package.json.
Not really sure how to fix this problem.
scripts": {
"start": "node scripts/start.js",
"start-3001": "set PORT=3001&& node scripts/start.js",
"start-3002": "set PORT=3002&& node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js --env=jsdom --verbose || exit 0"
},
"devDependencies": {
"enzyme-to-json": "^3.3.5",
"jes": "^0.6.1",
"jest": "^20.0.4",
"jest-fetch-mock": "^2.1.2",
"react-addons-test-utils": "^15.6.2",
"react-dom": "^15.6.2",
"react-test-renderer": "^15.5.4"
},
"jest": {
"automock": false,
"collectCoverageFrom": [
"src/**/*.{js,jsx}"
],
"setupFiles": [
"<rootDir>/config/polyfills.js"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.js?(x)",
"<rootDir>/src/**/?(*.)(spec|test).js?(x)"
],
"testEnvironment": "node",
"verbose": true,
"testURL": "http://localhost:3000",
"transform": {
"^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
],
"moduleNameMapper": {
"^react-native$": "react-native-web"
},
"moduleFileExtensions": [
"web.js",
"js",
"json",
"web.jsx",
"jsx",
"node"
]
},
"babel": {
"presets": [
"react-app",
"stage-0"
]
},
"eslintConfig": {
"extends": "react-app"
}
}
Upvotes: 0
Views: 10131
Reputation: 1
It update by clearing the npm cache via sudo
npm install -g n
Install a new version of Node
n lts
n latest
Check id version is update
npm -v 8.19.3
Upvotes: 0
Reputation: 1559
Delete node_modules and package-lock.json or yarn.lock files. Run npm install again and see if that fixes the issue.
Upvotes: 2