Why my travis conf fail to execute Angular test?
.travis.yml
language: node_js
node_js:
- "16"
addons:
chrome: stable
cache:
directories:
- ./node_modules
- ./.angular
install:
- npm install
script:
- npm run test -- --code-coverage --no-watch --no-progress --browsers=ChromeHeadlessCI
after_script:
- cat ./coverage/*/lcov.info | ./node_modules/coveralls/bin/coveralls.js
Error
ERROR [karma-server]: [39mError: Found 1 load error at Server. (/home/travis/build/node_modules/karma/lib/server.js:239:26) at Object.onceWrapper (node:events:509:28) at Server.emit (node:events:402:35) at Server.emit (node:domain:475:12) at emitListeningNT (node:net:1368:10) at processTicksAndRejections (node:internal/process/task_queues:82:21)
Full Log
> ng test "ng-simple-state" "--code-coverage" "--no-watch" "--no-progress" "--browsers=ChromeHeadlessCI"
[91m13 11 2021 19:17:19.850:ERROR [reporter]: [39mCan not load reporter "coverage", it is not registered!
Perhaps you are missing some plugin?
[32m13 11 2021 19:17:19.872:INFO [karma-server]: [39mKarma v6.3.8 server started at http://localhost:9876/
[32m13 11 2021 19:17:19.873:INFO [launcher]: [39mLaunching browsers ChromeHeadlessCI with concurrency unlimited
[91m13 11 2021 19:17:19.873:ERROR [karma-server]: [39mError: Found 1 load error
at Server.<anonymous> (/home/travis/build/node_modules/karma/lib/server.js:239:26)
at Object.onceWrapper (node:events:509:28)
at Server.emit (node:events:402:35)
at Server.emit (node:domain:475:12)
at emitListeningNT (node:net:1368:10)
at processTicksAndRejections (node:internal/process/task_queues:82:21)
travis_time:end:19df8806:start=1636831036436372127,finish=1636831039910258223,duration=3473886096,event=script
[0K[31;1mThe command "npm run test -- --code-coverage --no-watch --no-progress --browsers=ChromeHeadlessCI" exited with 1.[0m
travis_fold:start:cache.2
[0Kstore build cache
travis_time:start:26903718
[0Ktravis_time:end:26903718:start=1636831039914334654,finish=1636831039917048564,duration=2713910,event=cache
[0Ktravis_time:start:13baeaab
[0K[32;1mchanges detected, packing new archive[0m
[32;1muploading main/cache--linux-xenial-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855--node-16.tgz[0m
[32;1mcache uploaded[0m
travis_time:end:13baeaab:start=1636831039920798859,finish=1636831054568641990,duration=14647843131,event=cache
[0Ktravis_fold:end:cache.2
[0K
travis_fold:start:after_script
[0Ktravis_time:start:09c7f64c
[0K$ cat ./coverage/*/lcov.info | ./node_modules/coveralls/bin/coveralls.js
cat: './coverage/*/lcov.info': No such file or directory
[error] "2021-11-13T19:17:34.746Z" 'error from lcovParse: ' 'Failed to parse string'
[error] "2021-11-13T19:17:34.747Z" 'input: ' ''
[error] "2021-11-13T19:17:34.748Z" 'error from convertLcovToCoveralls'
/home/travis/build/node_modules/coveralls/bin/coveralls.js:19
throw err;
^
Failed to parse string
(Use `node --trace-uncaught ...` to show where the exception was thrown)
travis_time:end:09c7f64c:start=1636831054573043048,finish=1636831054753122792,duration=180079744,event=after_script
[0Ktravis_fold:end:after_script
[0K
Done. Your build exited with 1.
I assume that you upgraded your project to Angular 13. I replaced karma-coverage-istanbul-reporter with karma-coverage and it works fine.
In karma.conf.js, you should replace coverageIstanbulReporter with coverageReporter as follows
coverageReporter: {
dir: require('path').join(__dirname, './coverage/<your-project-name>'),
subdir: '.',
reports: [
{ type: 'html' },
{ type: 'lcovonly' },
{ type: 'text-summary' }
]
},
For more details, check this out. https://angular.io/guide/testing-code-coverage