无法让 coveralls.io 与 Travis CI 和 Jest 一起工作

问题描述

我无法让 Travis CI 和本地构建将覆盖信息发送到 coveralls.io。 Travis CI 和我的本地机器构建已在 coveralls.io 中成功捕获,但覆盖率仍然没有显示(0% 覆盖率)。
这是我的 GitHub repoTravis CIcoveralls.io 页面。

这是我的“脚本”值在 package.json 中的样子

[
  {
    _id: 6040fd38191f66368dfe4ca0,status: 'active',email: 'some.one@coolcompany.com',firstName: 'some',lastName: 'one',... many other fields,such as in the findOne()
  }
]

这是我的 travis.yml 文件

"scripts": {
    "pretest": "eslint .","test": "jest --coverage","test:coveralls": "jest --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage","test:coverallsLocal": "jest --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
  },

包括工作服的详细选项。结果如下:

language: node_js

node_js:
  - node

install:
  - npm ci --no-optional

script:
  - npm run test:coveralls

after_success:
  - echo -e "Test Success"

lcov.info 文件开头的这一部分:

> generator-vscode-typescript-jest@0.2.19 test:coverallsVerbose
> jest --coverage && cat ./coverage/lcov.info | coveralls -v
PASS __tests__/app.js
  generator-vscode-typescript-jest:app
    ✓ creates files (1 ms)
  console.warn
    yeoman-test: question website was asked but answer was not provided
      at CustomDummyPrompt.Object.<anonymous>.DummyPrompt.run (node_modules/yeoman-test/lib/adapter.js:43:15)
----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
----------|---------|----------|---------|---------|-------------------
All files |     100 |      100 |     100 |     100 |                   
 index.js |     100 |      100 |     100 |     100 |                   
----------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed,1 total
Tests:       1 passed,1 total
Snapshots:   0 total
Time:        2.4 s
Ran all test suites.
[debug] "2021-03-06T07:10:40.095Z"  'TN:\n' +
  'SF:../../home/travis/build/koonfoon/generator-vscode-typescript-jest/generators/app/index.js\n' +
  'FN:8,(anonymous_0)\n' +
  'FN:51,(anonymous_1)\n' +
  'FN:60,(anonymous_2)\n' +
  'FN:102,(anonymous_3)\n' +
  'FNF:4\n' +
  'FNH:4\n' +
  'FNDA:1,(anonymous_0)\n' +
  'FNDA:1,(anonymous_1)\n' +
  'FNDA:1,(anonymous_2)\n' +
  'FNDA:1,(anonymous_3)\n' +
  'DA:2,1\n' +
  'DA:3,1\n' +
  'DA:4,1\n' +
  'DA:5,1\n' +
  'DA:7,1\n' +
  'DA:10,1\n' +
  'DA:18,1\n' +
  'DA:51,1\n' +
  'DA:53,1\n' +
  'DA:54,1\n' +
  'DA:62,1\n' +
  'DA:66,1\n' +
  'DA:70,1\n' +
  'DA:74,1\n' +
  'DA:82,1\n' +
  'DA:92,1\n' +
  'DA:97,1\n' +
  'DA:98,1\n' +
  'DA:99,1\n' +
  'DA:103,1\n' +
  'LF:20\n' +
  'LH:20\n' +
  'BRF:0\n' +
  'BRH:0\n' +
  'end_of_record\n'
[debug] "2021-03-06T07:10:40.096Z"  'user options undefined'
[debug] "2021-03-06T07:10:40.103Z"  'No valid .coveralls.yml file found'
[debug] "2021-03-06T07:10:40.127Z"  {
  service_name: 'travis-ci',service_number: '33',service_job_id: '488741007',service_pull_request: 'false',run_at: '2021-03-06T07:10:40.101Z',git: {
    head: {
      id: 'HEAD',committer_name: 'koonfoon',committer_email: 'koonfoon@gmail.com',message: 'trigger travis ci build 3.09pm +semver: skip',author_name: 'koonfoon',author_email: 'koonfoon@gmail.com'
    },branch: 'master',remotes: [ [Object] ]
  }
}
[debug] "2021-03-06T07:10:40.129Z"  'in: ' ''
[info] "2021-03-06T07:10:40.133Z"  'sending this to coveralls.io: ' '{"source_files":[],"git":{"head":{"id":"HEAD","committer_name":"koonfoon","committer_email":"koonfoon@gmail.com","message":"trigger travis ci build 3.09pm +semver: skip","author_name":"koonfoon","author_email":"koonfoon@gmail.com"},"branch":"master","remotes":[{"name":"origin","url":"https://github.com/koonfoon/generator-vscode-typescript-jest.git"}]},"run_at":"2021-03-06T07:10:40.101Z","service_name":"travis-ci","service_number":"33","service_job_id":"488741007","service_pull_request":"false"}'
[debug] "2021-03-06T07:10:41.263Z"  200
[debug] "2021-03-06T07:10:41.264Z"  '{"message":"Job #33.1","url":"https://coveralls.io/jobs/76252693"}'
The command "npm run test:coverallsVerbose" exited with 0.
cache.2
store build cache
after_success
0.00s$ echo -e "Test Success"
Done. Your build exited with 0.

总是绝对路径,我觉得应该是相对路径,比如:

'SF:../../home/travis/build/koonfoon/generator-vscode-typescript-jest/generators/app/index.js\n'

但是如何制作相对路径?

这是构建的 link

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...