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

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

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:

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: ['<rootDir>/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.

答案1

得分: 0

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

 运行  example-Stack.test.ts
 运行  example-Stack.test.ts
 运行  example-Stack.test.ts
 通过  example-Stack.test.ts

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

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

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

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

英文:

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

 RUNS  example-Stack.test.ts
 RUNS  example-Stack.test.ts
 RUNS  example-Stack.test.ts
 PASS  example-Stack.test.ts

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

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

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

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:

确定