Running a few tests for react js using Jest and Enzyme but one of the files keep 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 aninitialization 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": "", "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" } }
1

1 Answer

Delete node_modules and package-lock.json or yarn.lock files. Run npm install again and see if that fixes the issue.

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy