0

Now building a react app made by create-react-app.

In my package.json, I installed some dependencies. The full list is here:

package.json

{
  "name": "app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  },
  "dependencies": {
    "jest-cli": "^22.4.3",
    "raven-js": "^3.25.1",
    "react": "^16.3.2",
    "react-raven": "^1.2.3",
    "react-scripts": "1.1.4",
    "babel-plugin-add-module-exports": "0.2.1"
  },
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-jest": "^22.4.3",
    "babel-polyfill": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "babel-preset-react-app": "^3.1.1",
    "coveralls": "^3.0.1",
    "enzyme": "^3.3.0",
    "enzyme-adapter-react-16": "^1.1.1",
    "jest": "^22.4.3",
    "react-addons-test-utils": "^15.6.2",
    "react-dom": "^16.3.2",
    "react-test-renderer": "^16.3.2"
  }
}

Also created a .travis.yml file. Want to test the codes on TravisCI:

.travis.yml

language: node_js
node_js:
  - "8"

before_script:
  - npm install
  - npm install coveralls

script:
  - jest --coverage --coverageReporters=text-lcov | coveralls

But when the TravisCI run the task, it's console log shows:

...
$ jest --coverage --coverageReporters=text-lcov | coveralls
PASS src/sum.test.js
  ✓ adds 1 + 2 to equal 3 (7ms)
Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        2.629s
Ran all test suites.
/home/travis/build/[MY_GITHUB]/[MY_PROJECT]/node_modules/coveralls/bin/coveralls.js:18
        throw err;
        ^
Bad response: 500 {"message":"Build processing error.","error":true,"url":""}
The command "jest --coverage --coverageReporters=text-lcov | coveralls" exited with 1.
Done. Your build exited with 1.

Why can't send coverage result to coveralls?

v v
  • 613
  • 3
  • 10
  • 26

1 Answers1

1

I have put together a simple repository to demonstrate using jest with travis and coveralls here:

https://github.com/AaronWatters/hello_jest

It uses jest.config.js to tell jest to put the coverage report at "./tests/coverage" and then the coveralls directive in package.json is

"coveralls": "jest --coverage && cat ./tests/coverage/lcov.info | coveralls",

I'm sorry it is so convoluted but it seems to work even though it's not as simple as what you were trying to do. It also does not use react but I don't think it should be an issue to use the same approach with a react component.

Please see the repository for all the gory details.

Also please post an issue at the repository if you find problems with the approach or if you have other suggestions or comments.

Aaron Watters
  • 2,784
  • 3
  • 23
  • 37