如何通过 `npm run test` 获取更多信息?

huangapple go评论104阅读模式
英文:

How do I get more information with `npm run test`?

问题

I am running npm run test with Jest and am receiving very little information in the CLI:

Test Suites: 1 failed, 19 passed, 20 total
Tests: 238 passed, 238 total
Snapshots: 0 total
Time: 742.958 s
Ran all test suites.

jest.config.js:

module.exports = {
testEnvironment: 'node',
roots: ['/test'],
testMatch: ['**/*.test.ts'],
transform: {
'^.+\.tsx?$': 'ts-jest'
}
};

package.json:

"scripts": {
"test": "jest",
},

How can I obtain more information? For example, information about which suite failed or a table of all the tests for each suite.

英文:

I am running npm run test with Jest and am receiving very little information in the CLI:

  1. Test Suites: 1 failed, 19 passed, 20 total
  2. Tests: 238 passed, 238 total
  3. Snapshots: 0 total
  4. Time: 742.958 s
  5. Ran all test suites.

jest.config.js:

  1. module.exports = {
  2. testEnvironment: 'node',
  3. roots: ['<rootDir>/test'],
  4. testMatch: ['**/*.test.ts'],
  5. transform: {
  6. '^.+\\.tsx?$': 'ts-jest'
  7. }
  8. };

package.json:

  1. "scripts": {
  2. "test": "jest",
  3. },

How can I obtain more information? For example, information about which suite failed or a table of all the tests for each suite.

答案1

得分: 0

运行npm run test使用jest将不提供单个测试套件的成功报告,结果将如下所示:

  1. 运行 example-Stack.test.ts
  2. 运行 example-Stack.test.ts
  3. 运行 example-Stack.test.ts
  4. 通过 example-Stack.test.ts

测试套件:1 个失败,19 个通过,共计 20 个
测试:238 个通过,共计 238 个
快照:共计 0 个
时间:742.958 秒
已运行所有测试套件。

要获取多个测试套件的单独测试信息,请在脚本文件中使用jest --verbose

  1. "scripts": {
  2. "test": "jest --verbose",
  3. },

这将显示有关每个测试的信息,就像您在运行单个测试文件时所经历的那样。

英文:

Running npm run test with jest will not offer individual suite success reporting, and will offer the answer like this:

  1. RUNS example-Stack.test.ts
  2. RUNS example-Stack.test.ts
  3. RUNS example-Stack.test.ts
  4. PASS example-Stack.test.ts
  5. Test Suites: 1 failed, 19 passed, 20 total
  6. Tests: 238 passed, 238 total
  7. Snapshots: 0 total
  8. Time: 742.958 s
  9. Ran all test suites.

To obtain the individual test information for multiple suites, use jest --verbose in the scripts file:

  1. "scripts": {
  2. "test": "jest --verbose",
  3. },

This will show information about each test like you would experience running an individual test file.

huangapple
  • 本文由 发表于 2023年3月9日 18:48:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/75683558.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定