首页 > 解决方案 > 为什么 Ava js 在本地不显示错误日志,仅在 ci 中

问题描述

我有一个失败的 ava 测试应该像这样出错:

$ npm run test
> fetch_courses@1.0.0 test /home/travis/build/********/fetch_courses
> tsc && ava
  Uncaught exception in test/fetchTerms.test.ts
  Error: Cannot find module '../config.js'
  Require stack:
  - /home/travis/build/********/fetch_courses/src/fetchTerms.ts
  - /home/travis/build/********/fetch_courses/test/fetchTerms.test.ts
  - /home/travis/build/********/fetch_courses/node_modules/ava/lib/worker/subprocess.js
  › - node_modules/ava/lib/worker/subprocess.js
  › src/fetchTerms.ts:2:1
  › Object.<anonymous> (src/fetchTerms.ts:139:4)
  › Module.m._compile (node_modules/ts-node/src/index.ts:858:23)
  › require.extensions.<computed> (node_modules/ts-node/src/index.ts:861:12)
  ✖ test/fetchTerms.test.ts exited with a non-zero exit code: 1
  ─
  1 uncaught exception
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fetch_courses@1.0.0 test: `tsc && ava`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the fetch_courses@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/travis/.npm/_logs/2020-07-21T21_30_16_127Z-debug.log
The command "npm run test" exited with 1.
cache.2
store build cache

这只发生在我的 travis 构建中。

当我新克隆 [我的存储库][1] 并运行npm installandnpm run test时,这正是 travis 中发生的情况,这就是我看到的日志记录。

$ npm run test

> fetch_courses@1.0.0 test /mnt/c/Users/********/Projects/fetch_courses
> tsc && ava


npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fetch_courses@1.0.0 test: `tsc && ava`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fetch_courses@1.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /mnt/c/Users/********/.npm/_logs/2020-07-21T22_06_02_028Z-debug.log

所以你可以看到我错过了整个 Ava 输出/错误记录。

我不知道我还能做什么,但也许这是某种配置问题?存储库已链接,因此请随意浏览和/或尝试复制。

标签: node.jstypescriptnpmtravis-ciava

解决方案


找不到答案,因为这个问题似乎仅限于我的 IDE,所以我的解决方法是在已编译的 javascript 版本的测试上运行 ava。无论出于何种原因,日志记录在那里工作。


推荐阅读