获取使用Jest运行的测试列表(没有运行套件) [英] Getting a list of tests run with Jest (without running suites)

查看:58
本文介绍了获取使用Jest运行的测试列表(没有运行套件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在不运行带有Jest的实际测试的情况下获得套件/规格的列表.

Is it possible to get a list of suites/specs without running the actual tests w/ Jest.

例如,我有一个看起来像这样的测试:

For example, I have a test that looks like this:

describe('when blah blah blah', function () {
  it('returns foobar', function () { /* test code */ })
})

理想情况下,我希望能够仅获得describe/it语句列表,以快速查看所涵盖的场景.

Ideally, I'd like to be able to just get a list of describe/it statements to quickly look at scenarios covered.

# stdout
when blah blah blah
  returns foobar

我认为使用 dry-run 标志使用rspec可以做到这一点.Jest有这样的选择吗?

I think this is possible with rspec, using a dry-run flag. Is there any such option with Jest?

我看了一下Jest CLI文档,并在项目的Github页面上进行了问题搜索,但是找不到任何东西.

I took a look at the Jest CLI documentation and have done an issue search at the project's Github page, but could not find anything.

推荐答案

开关-listTests 返回测试文件的JSON数组,然后退出(而不是运行测试).

The switch --listTests returns a JSON array of the test files and then exits (instead of running the tests).

尽管它可能无法完全解析出您要查找的内容, describe / it 函数,输出也不是很漂亮.

It might not be exactly what you're looking for though since it doesn't parse the describe/it functions, nor is the output very pretty.

https://facebook.github.io/jest/docs/zh/cli.html#listtests

这篇关于获取使用Jest运行的测试列表(没有运行套件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆