英文:
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: ['
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论