No
Yes
(Write your answer here if relevant.)
node -v: 8.6.0npm -v: 5.3.0yarn --version (if you use Yarn):npm ls react-scripts (if you haven鈥檛 ejected): 1.1.1Then, specify:
(Write your steps here:)
Exit successfully (NOT with an exit status of 1) after running tests and collecting coverage data.
Tests run (most fail, but that's fine for now), and coverage data is collected and printed out to systdout, but the run always finishes with an exit status of 1 (npm ERR! code ELIFECYCLE).
My project: https://github.com/WycliffeAssociates/translationExchange/
Branch: nd_jenkins_config
PLEASE NOTE: My work is only on this branch. You need to be on this branch to reproduce my issue.
To add a little more premise to my problem, I am trying to take my team's github project and integrate jenkins to run the tests and report code coverage. Therefore, I am trying to get Jest to run all our tests without prompting for any input (since Jenkins can't do that for us). I am using Jest-Junit as the test results processor. I create my own npm command in my package.json file called "test:ci", which runs all the tests without needing any input from the user by adding the "--coverage" argument. Every time I run this command, all my tests run and my code coverage is reported, but the job exits with a status of 1 on my machine. The same happens when I run it as a job in jenkins in a shell command on a remote machine. This would cause an issue for me because I don't want our jenkins job to fail due to code coverage.
Looking at posts from other people with similar issues, I've narrowed down that it's not an OS issue, it has nothing to do with my coverage threshold (verified by only collecting coverage data from a file that has 100% coverage and still getting the 1 exit status), and removing my node_modules and package-lock,json, clearing the cache, then running 'npm install' doesn't fix my issue either. Are there other suggestions on how to stop getting the following output:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:ci: cross-env NODE_PATH=src react-scripts test --coverage --collectCoverageFrom=src/js/actions/types.js --testResultsProcessor ./node_modules/jest-junit
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test:ci script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
?
Here is a copy of my log output:
2018-03-22T15_15_56_132Z-debug.log
Here is a copy of my package.json:
{
"name": "translationexchange",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.16.2",
"classnames": "^2.2.5",
"cross-env": "^5.0.1",
"express": "^4.16.2",
"fast-deep-equal": "^1.0.0",
"howler": "^2.0.4",
"js-base64": "^2.1.9",
"json-schema-traverse": "^0.3.1",
"lodash": "latest",
"nearest-neighbor": "^0.0.3",
"nock": "^9.0.14",
"prop-types": "^15.6.0",
"query-string": "^4.3.4",
"react": "^15.6.1",
"react-addons": "^0.9.1-deprecated",
"react-addons-create-fragment": "^15.6.0",
"react-addons-css-transition-group": "^15.6.0",
"react-addons-transition-group": "^15.6.0",
"react-audio-player": "^0.5.0",
"react-audioplayer": "^0.3.0",
"react-axios": "^1.0.2",
"react-circular-progressbar": "^0.1.5",
"react-dnd": "^2.4.0",
"react-dnd-multi-backend": "^3.0.4",
"react-dnd-touch-backend": "^0.3.15",
"react-file-input": "^0.2.5",
"react-howler": "^3.6.2",
"react-mic": "^7.1.6",
"react-notify-toast": "^0.3.2",
"react-rating": "^0.8.1",
"react-read-more": "^1.0.0",
"react-redux": "^5.0.6",
"react-responsive-audio-player": "^1.1.4",
"react-router-bootstrap": "^0.24.2",
"react-router-dom": "^4.1.1",
"react-scripts": "^1.0.7",
"react-stars": "^2.1.0",
"react-transition-group": "^1.2.0",
"react-wavesurfer": "^0.8.6",
"redux-devtools-extension": "^2.13.2",
"redux-logger": "^3.0.6",
"redux-mock-store": "^1.3.0",
"redux-thunk": "^2.2.0",
"semantic-ui-css": "^2.2.11",
"semantic-ui-react": "^0.71.0",
"translation-audio-player": "^1.4.0",
"wavesurfer.js": "^1.4.0",
"webpack": "^3.6.0"
},
"devDependencies": {
"axios-mock-adapter": "^1.10.0",
"babel-core": "^6.26.0",
"babel-jest": "^20.0.3",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"cross-env": "^5.0.1",
"enzyme": "^3.2.0",
"enzyme-adapter-react-15": "^1.0.5",
"enzyme-to-json": "^3.3.0",
"fetch-mock": "^5.13.1",
"jest": "^20.0.4",
"jest-cli": "^20.0.4",
"jest-junit": "^3.6.0",
"moxios": "^0.4.0",
"react-addons-test-utils": "^15.6.0",
"react-scripts": "^1.0.7",
"react-test-renderer": "^15.6.1",
"sinon": "^4.1.3",
"web-audio-mock": "^0.1.9",
"webpack": "^3.6.0"
},
"scripts": {
"start": "cross-env NODE_PATH=src react-scripts start",
"build": "cross-env NODE_PATH=src react-scripts build",
"test": "cross-env NODE_PATH=src react-scripts test",
"test:ci": "cross-env NODE_PATH=src react-scripts test --coverage --collectCoverageFrom=src/js/actions/types.js ",
"eject": "react-scripts eject"
},
"jest": {
"coverageReporters": [
"lcov",
"text"
],
"coverageThreshold": {
"global": {
"branches": 0,
"functions": 0,
"lines": 0,
"statements": 0
}
}
},
"jest-junit": {
"suitName": "jest tests",
"output": "src/__test__/junit.xml",
"classNameTemplate": "{classname} - {title}",
"titleTemplate": "{classname} - {title}",
"ancestorSeparator": " > ",
"usePathForSuitName": "true"
},
"proxy": "http://translationExchange:8080"
}
Any help/suggestions in getting the rid of the exit status 1 would be helpful.
You've installed many packages along-side react-scripts which is not supported (jest, babel, webpack, etc). Please move your react-scripts app into its own repo.
@Timer , I'm sorry but could you elaborate a little more? I'm not very familiar with 'create-react-app'. Are you saying that many of the dependencies included in the package.json file do not need to be there? I read some of the documentation for create-react-scripts. Is my understanding correct that by including 'react-scripts' in the package.json, it includes functionality for jest, webpack, etc.?
Nvm, I was able to find somewhat of a hacky solution for myself. By running npm run test:ci --silent in my Jenkins job, I was able to get npm to ignore the error without returning false positives to Jenkins. My test:ci script looks like this in my package.json file "test:ci" : cross-env NODE_PATH=src react-scripts test --coverage. Using the above configurations will get Jenkins to run my tests without returning any npm errors.
Correct, having react-scripts makes babel, jest, webpack, etc all unnecessary.
Just an FYI this will throw an error in the upcoming release (2.0).