0

I try to make nyc working with coveralls following the instruction: https://github.com/istanbuljs/nyc#integrating-with-coveralls

But I can't get it to work. Here is an example repo: https://github.com/unional/showdown-highlightjs-extension

Travis build is successful: https://travis-ci.org/unional/showdown-highlightjs-extension

And Coveralls notice the build, but does not seem to get any data: https://coveralls.io/github/unional/showdown-highlightjs-extension

Here is my .travis.yml:

language: node_js

notifications:
  email:
    on_success: never
    on_failure: change

node_js:
  - "stable"

before_install:
  - npm install -g npm

script:
  - npm run verify

after_script:
  - npm install coveralls && npm run coveralls

And here is my package.json:

{
  ...
  "scripts": {
    "coverage": "npm test && nyc check-coverage --branches 85 --functions 85 --lines 85",
    "coveralls": "nyc report --reporter=text-lcov | coveralls",
    "test": "npm run clean && tsc && nyc ava"
    ...
  },
  "nyc": {
    "exclude": [
      "scripts",
      "**/*.spec.*",
      "**/fixtures/**/*"
    ]
  },
  ...
}
unional
  • 14,651
  • 5
  • 32
  • 56

2 Answers2

2

Try adding your Coveralls repo API token (which can be found on the Coveralls page for your repo) to a new COVERALLS_REPO_TOKEN encrypted environment variable on Travis, as per the (somewhat sketchy) documentation on the Coveralls site.

ocean
  • 1,335
  • 15
  • 26
  • Thanks, I tried adding the `COVERALLS_REPO_TOKEN`, but it still say "no data" in the coveralls site. – unional Jan 09 '17 at 07:53
  • travis: https://travis-ci.org/unional/global-store coveralls: https://coveralls.io/github/unional/global-store – unional Jan 09 '17 at 07:53
  • Hmm. Try merging the two `coverage` and `coveralls` npm script commands together, so your `nyc report ...` command gets run straight after the `test` and `check-coverage` commands. Maybe one of your other `npm` script commands is deleting the test coverage files that `nyc` is creating. – ocean Jan 09 '17 at 08:08
  • Also make sure that your Typescript transpilation is generating source maps, as `ava` tests [use those for coverage checking](https://www.npmjs.com/package/ava#code-coverage). – ocean Jan 09 '17 at 08:17
  • I tried a few things and it still not working. I print out the result from `nyc report ...` to show that it does have the data when it is being piped to `coveralls`. You can see it here: https://s3.amazonaws.com/archive.travis-ci.org/jobs/190190241/log.txt (scroll to the end) – unional Jan 09 '17 at 18:51
  • Maybe try deleting the Coveralls pages for your repos, and re-creating them? – ocean Jan 10 '17 at 08:05
  • They are new repos added to coveralls. I will give it a try anyway. :) – unional Jan 10 '17 at 09:17
  • Sorry, I have no more ideas. I even tried forking and running my own tests, I didn't get any Coveralls data either, then I tried CodeCov and that didn't get any either ( https://travis-ci.org/ocean/global-store ). I don't know much about Typescript, maybe something in there is not configured right? – ocean Jan 10 '17 at 09:46
  • Thanks for you help. I know it is working, e.g. https://github.com/typings/core So need to figure out what's the difference. (one different is using different test framework). – unional Jan 10 '17 at 20:29
1

I found out the issue is in my tsconfig.json:

{
  "compilerOptions": {
    "sourceRoot": "/showdown-highlight-extension"
    ...
  }
}

This setting gives me the correct (I assume) source map in the browser. See What's the proper way to set sourceRoot in typescript?

image

But is not liked by the coverage tool.

Once I remove it, it starts working.

Need to find an answer to that question.

Community
  • 1
  • 1
unional
  • 14,651
  • 5
  • 32
  • 56