运行笑话测试时是否可以显示所有测试说明?

编程入门 行业动态 更新时间:2024-10-28 00:18:13
本文介绍了运行笑话测试时是否可以显示所有测试说明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在我的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.

更多推荐

运行笑话测试时是否可以显示所有测试说明?

本文发布于:2023-11-16 18:56:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1606938.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:测试   笑话

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!