运行笑话测试时是否可以显示所有测试说明? [英] Is there an option to show all test descriptions when I run jest tests?
问题描述
我在我的create-react-app项目中使用笑话和酵素.当我运行npm test
时,我得到一个输出,该输出显示已通过的测试文件的名称,但我希望该输出还包括测试的名称.
I'm using jest and enzyme with my create-react-app project. When I run npm test
, I get an output that shows the names of the test files that passed but I'd like the output to also include the names of the tests.
示例:
Button.test.js
Button.test.js
it ('renders button', () => {
const button = shallow(<Button type="save"/>);
expect(toJson(button)).toMatchSnapshot();
});
现在,当我运行npm test时,输出仅为:
Right now when I run npm test the output is just:
通过src/Button.test.js"
PASS src/Button.test.js"
以及通过和失败的测试数(测试成功时).我希望输出包含"renders button"和任何其他测试描述(例如运行rspec测试时输出的外观).
and the number of passed and failed tests (when the tests are successful). I would like the output to include "renders button" and any other test descriptions (like how the output looks when an rspec test is run).
推荐答案
来自 Jest的命令行选项文档
-冗长
显示带有测试套件层次结构的单个测试结果.
Display individual test results with the test suite hierarchy.
如此运行
jest --verbose
将在describe
,it
,test
块中打印所有名称.
如果您正在使用yarn
运行测试,则可以
Will print all the names in describe
, it
, test
blocks.
If you're running tests with yarn
, you can do
yarn test --verbose
如果您正在使用npm
运行测试,则可以
If you're running tests with npm
, you can do
npm test -- --verbose
如果要将其设置为默认值,请在package.json
If you want to make this default, change your test script in package.json
"test": "react-scripts test --env=jsdom --verbose",
现在yarn test
和npm test
都应显示所有测试名称.
Now both yarn test
and npm test
should show all test names.
这篇关于运行笑话测试时是否可以显示所有测试说明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!