Skip to content

Commit f253935

Browse files
committed
#15759 Fix it.concurrent not working with describe.skip
1 parent fe7f28c commit f253935

File tree

4 files changed

+148
-5
lines changed

4 files changed

+148
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## main
22

3+
### Fixes
4+
5+
- `[jest-each]` Fix `it.concurrent` not working with `describe.skip` ([#tbd](https://github.com/jestjs/jest/pull/tbd))
6+
37
## 30.0.5
48

59
### Features

packages/jest-circus/src/__tests__/__snapshots__/baseTest.test.ts.snap

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,107 @@ run_finish
7272
unhandledErrors: 0"
7373
`;
7474

75+
exports[`describe + concurrent should pass 1`] = `
76+
"start_describe_definition: describe
77+
add_hook: beforeEach
78+
add_hook: afterEach
79+
add_test: one
80+
add_test: two
81+
finish_describe_definition: describe
82+
run_start
83+
run_describe_start: ROOT_DESCRIBE_BLOCK
84+
run_describe_start: describe
85+
test_start: one
86+
test_started: one
87+
hook_start: beforeEach
88+
hook_success: beforeEach
89+
test_fn_start: one
90+
test_fn_success: one
91+
hook_start: afterEach
92+
hook_success: afterEach
93+
test_done: one
94+
test_start: two
95+
test_started: two
96+
hook_start: beforeEach
97+
hook_success: beforeEach
98+
test_fn_start: two
99+
test_fn_success: two
100+
hook_start: afterEach
101+
hook_success: afterEach
102+
test_done: two
103+
run_describe_finish: describe
104+
run_describe_finish: ROOT_DESCRIBE_BLOCK
105+
run_finish
106+
107+
unhandledErrors: 0"
108+
`;
109+
110+
exports[`describe.skip + concurrent 1`] = `
111+
"start_describe_definition: describe
112+
add_hook: beforeEach
113+
add_hook: afterEach
114+
add_test: one
115+
add_test: two
116+
add_test: three
117+
finish_describe_definition: describe
118+
run_start
119+
run_describe_start: ROOT_DESCRIBE_BLOCK
120+
run_describe_start: describe
121+
test_start: one
122+
test_start: two
123+
test_start: three
124+
test_skip
125+
test_skip
126+
test_skip
127+
run_describe_finish: describe
128+
run_describe_finish: ROOT_DESCRIBE_BLOCK
129+
run_finish
130+
131+
unhandledErrors: 0"
132+
`;
133+
134+
exports[`describe.skip + concurrent.each 1`] = `
135+
"start_describe_definition: describe
136+
add_hook: beforeEach
137+
add_hook: afterEach
138+
add_test: one
139+
add_test: two
140+
add_test: three
141+
finish_describe_definition: describe
142+
run_start
143+
run_describe_start: ROOT_DESCRIBE_BLOCK
144+
run_describe_start: describe
145+
test_start: one
146+
test_start: two
147+
test_start: three
148+
test_skip
149+
test_skip
150+
test_skip
151+
run_describe_finish: describe
152+
run_describe_finish: ROOT_DESCRIBE_BLOCK
153+
run_finish
154+
155+
unhandledErrors: 0"
156+
`;
157+
158+
exports[`describe.skip + test.concurrent 1`] = `
159+
"start_describe_definition: describe
160+
add_hook: beforeEach
161+
add_hook: afterEach
162+
add_test: one
163+
finish_describe_definition: describe
164+
run_start
165+
run_describe_start: ROOT_DESCRIBE_BLOCK
166+
run_describe_start: describe
167+
test_start: one
168+
test_skip
169+
run_describe_finish: describe
170+
run_describe_finish: ROOT_DESCRIBE_BLOCK
171+
run_finish
172+
173+
unhandledErrors: 0"
174+
`;
175+
75176
exports[`failures 1`] = `
76177
"start_describe_definition: describe
77178
add_hook: beforeEach

packages/jest-circus/src/__tests__/baseTest.test.ts

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,48 @@ test('concurrent.each', () => {
7676
['three'],
7777
])('%s', async (name) => {
7878
console.log('hello %s', name);
79-
await Promise.resolve();
79+
await Promise.resolve();
80+
});
81+
})
82+
`);
83+
84+
expect(stdout).toMatchSnapshot();
85+
});
86+
87+
test('describe.skip + concurrent', () => {
88+
const {stdout} = runTest(`
89+
describe.skip('describe', () => {
90+
beforeEach(() => {});
91+
afterEach(() => { throw new Error('banana')});
92+
test.concurrent('one', () => {
93+
console.log('hello one');
94+
throw new Error('kentucky')
95+
});
96+
test.concurrent('two', () => {
97+
console.log('hello two');
98+
});
99+
test.concurrent('three', async () => {
100+
console.log('hello three');
101+
await Promise.resolve();
102+
});
103+
})
104+
`);
105+
106+
expect(stdout).toMatchSnapshot();
107+
});
108+
109+
test('describe.skip + concurrent.each', () => {
110+
const {stdout} = runTest(`
111+
describe.skip('describe', () => {
112+
beforeEach(() => {});
113+
afterEach(() => { throw new Error('banana')});
114+
test.concurrent.each([
115+
['one'],
116+
['two'],
117+
['three'],
118+
])('%s', async (name) => {
119+
console.log('hello %s', name);
120+
await Promise.resolve();
80121
});
81122
})
82123
`);

packages/jest-circus/src/run.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const _runTestsForDescribeBlock = async (
6363

6464
if (isRootBlock) {
6565
const concurrentTests = collectConcurrentTests(describeBlock);
66-
if (concurrentTests.length > 0) {
66+
if (concurrentTests.length > 0 && describeBlock.mode !== 'skip') {
6767
startTestsConcurrently(concurrentTests, isSkipped);
6868
}
6969
}
@@ -169,9 +169,6 @@ const _runTestsForDescribeBlock = async (
169169
function collectConcurrentTests(
170170
describeBlock: Circus.DescribeBlock,
171171
): Array<ConcurrentTestEntry> {
172-
if (describeBlock.mode === 'skip') {
173-
return [];
174-
}
175172
return describeBlock.children.flatMap(child => {
176173
switch (child.type) {
177174
case 'describeBlock':

0 commit comments

Comments
 (0)