Skip to content

Commit 14cf63d

Browse files
committed
add e2e concurrent testing
1 parent f28f669 commit 14cf63d

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

e2e/__tests__/toMatchNamedSnapshot.test.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,3 +289,51 @@ test('handles property matchers with deep properties', () => {
289289
expect(exitCode).toBe(1);
290290
}
291291
});
292+
293+
test('support concurrent testing', () => {
294+
const filename = 'match-snapshot-when-test-concurrent.test.js';
295+
const template = makeTemplate(`describe('group 1', () => {
296+
$1('concurrent 1', async () => {
297+
expect('concurrent 1-1').toMatchNamedSnapshot('test1');
298+
$2
299+
});
300+
301+
$1('concurrent 2', async () => {
302+
expect('concurrent 1-2').toMatchNamedSnapshot('test2');
303+
$2
304+
});
305+
});
306+
307+
describe('group 2', () => {
308+
$1('concurrent 1', async () => {
309+
expect('concurrent 2-1').toMatchNamedSnapshot('test3');
310+
$2
311+
});
312+
313+
$1('concurrent 2', async () => {
314+
expect('concurrent 2-2').toMatchNamedSnapshot('test4');
315+
$2
316+
});
317+
});
318+
`);
319+
{
320+
writeFiles(TESTS_DIR, {[filename]: template(['test'])});
321+
const {stderr, exitCode} = runJest(DIR, ['-w=1', '--ci=false', filename]);
322+
console.log(stderr);
323+
324+
expect(exitCode).toBe(0);
325+
}
326+
327+
{
328+
writeFiles(TESTS_DIR, {
329+
[filename]: template([
330+
'test.concurrent',
331+
'await new Promise(resolve => setTimeout(resolve, 5000));',
332+
]),
333+
});
334+
const {stderr, exitCode} = runJest(DIR, ['-w=1', '--ci=false', filename]);
335+
console.log(stderr);
336+
337+
expect(exitCode).toBe(0);
338+
}
339+
});

e2e/__tests__/toMatchSnapshot.test.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,3 +304,51 @@ test('handles property matchers with deep properties', () => {
304304
expect(exitCode).toBe(1);
305305
}
306306
});
307+
308+
test('does not support concurrent testing', () => {
309+
const filename = 'match-snapshot-when-test-concurrent.test.js';
310+
const template = makeTemplate(`describe('group 1', () => {
311+
$1('concurrent 1', async () => {
312+
expect('concurrent 1-1').toMatchSnapshot();
313+
$2
314+
});
315+
316+
$1('concurrent 2', async () => {
317+
expect('concurrent 1-2').toMatchSnapshot();
318+
$2
319+
});
320+
});
321+
322+
describe('group 2', () => {
323+
$1('concurrent 1', async () => {
324+
expect('concurrent 2-1').toMatchSnapshot();
325+
$2
326+
});
327+
328+
$1('concurrent 2', async () => {
329+
expect('concurrent 2-2').toMatchSnapshot();
330+
$2
331+
});
332+
});
333+
`);
334+
{
335+
writeFiles(TESTS_DIR, {[filename]: template(['test'])});
336+
const {stderr, exitCode} = runJest(DIR, ['-w=1', '--ci=false', filename]);
337+
338+
expect(stderr).toMatch('4 snapshots written');
339+
expect(exitCode).toBe(0);
340+
}
341+
342+
{
343+
writeFiles(TESTS_DIR, {
344+
[filename]: template([
345+
'test.concurrent',
346+
'await new Promise(resolve => setTimeout(resolve, 5000));',
347+
]),
348+
});
349+
const {stderr, exitCode} = runJest(DIR, ['-w=1', '--ci=false', filename]);
350+
351+
expect(stderr).toMatch('snapshots obsolete');
352+
expect(exitCode).toBe(1);
353+
}
354+
});

0 commit comments

Comments
 (0)