【发布时间】:2022-02-18 15:49:01
【问题描述】:
我有以下测试设置:
describe(`my tests`, () => {
describe(`Should not run`, () => {
console.log(`Should not be printed`);
describe(`Should also not run`, () => {
console.log(`Should also not be printed`);
test(`Then an exception is thrown`, () => {
console.log(`Should definitely not be printed`);
throw new Error(`whoops`);
})
})
describe(`Should run`, () => {
console.log(`Should run`)
test(`Then I should get this list in the format I expect`, () => {
console.log(`Should definitely be printed`);
})
})
describe(`Should not run`, () => {
console.log(`Should not be printed`);
test(`Then I should get an empty list`, () => {
throw new Error(`whoops`);
})
})
})
})
当我要求 IntelliJ 仅运行测试用例 test('Then I should get this list in the format I expect') 时,我仍然得到以下输出:
> Should not be printed
> Should also not be printed
> Should run
> Should not be printed
> Should definitely be printed
其他describe 块的代码怎么会被执行?我认为describe 块允许您确定测试设置的范围,以便它仅针对该特定块内的测试运行。
【问题讨论】:
-
使用
describe.only -
无法在 2021.3.2 中重现 - 仅运行选定的测试(使用装订线中的图标开始测试时)。用 jest@25 和 jest@27 测试。您使用哪些 IDE 和 Jest 版本?
-
使用 jest
24.9.0和 IDE IntelliJ IDEA 2021.2.3(终极版) -
在使用 jest 27 的项目中运行相同的测试时,我仍然得到相同的行为
标签: javascript node.js intellij-idea jestjs