【问题标题】:How to specify the order of running spec files with jest ? E.g: run first spec.fille1.js then spec.file2.js etc如何用 jest 指定运行规范文件的顺序?例如:先运行 spec.fille1.js 然后运行 ​​spec.file2.js 等
【发布时间】:2020-06-18 14:36:51
【问题描述】:

我想按以下顺序运行我的规范文件:

spec.file2.js,

spec.file3.js,

spec.file5.js,

spec.file1.js

我想用玩笑来配置它。需要帮助...

【问题讨论】:

  • 这是你真正想要的吗?这些单元测试的想法是它们彼此独立并且可以以任何顺序运行。开始相互依赖的测试,随着时间的推移将变得更难维护,并添加额外的依赖关系,这也会使重构代码更加困难。

标签: express ecmascript-6 jestjs


【解决方案1】:

如本链接所述,https://github.com/facebook/jest/issues/6194

有一个索引文件,称为 index.spec.js,它规定了您执行的顺序:

require('./spec.file2.js')
require('./spec.file3.js')
require('./spec.file5.js')
require('./spec.file1.js')

只要确保没有其他相关测试与开玩笑的默认 testMatch 匹配,除非另有自定义定义

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-08-13
    • 2013-02-15
    • 1970-01-01
    • 2020-08-26
    • 2021-10-04
    • 2015-12-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多