Skip to content

Commit

Permalink
Add more e2e tests, ensure concurrent tests end with a time gap
Browse files Browse the repository at this point in the history
  • Loading branch information
madcapnmckay committed Jan 6, 2025
1 parent 3e5bb4d commit 99ada77
Show file tree
Hide file tree
Showing 6 changed files with 437 additions and 53 deletions.
212 changes: 179 additions & 33 deletions e2e/__tests__/__snapshots__/circusConcurrent.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,84 +1,230 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`runs the tests in the correct order 1`] = `
exports[`all passing runs the tests in the correct order 1`] = `
" console.log
[[beforeAll]]
beforeAll
at log (__tests__/concurrent.test.js:12:29)
at log (__tests__/concurrent.test.js:15:11)
console.log
[[test one start]]
START "one"
at log (__tests__/concurrent.test.js:12:29)
at log (__tests__/concurrent.test.js:15:11)
console.log
[[test three start]]
START "two"
at log (__tests__/concurrent.test.js:12:29)
at log (__tests__/concurrent.test.js:15:11)
console.log
[[test five start]]
START "three"
at log (__tests__/concurrent.test.js:12:29)
at log (__tests__/concurrent.test.js:15:11)
console.log
[[test six start]]
START "four"
at log (__tests__/concurrent.test.js:12:29)
at log (__tests__/concurrent.test.js:15:11)
console.log
[[test seven (fails) start]]
START "five"
at log (__tests__/concurrent.test.js:12:29)
at log (__tests__/concurrent.test.js:15:11)
console.log
[[test three end]]
END: "three"
at log (__tests__/concurrent.test.js:12:29)
at log (__tests__/concurrent.test.js:15:11)
console.log
[[test eight start]]
START "six"
at log (__tests__/concurrent.test.js:12:29)
at log (__tests__/concurrent.test.js:15:11)
console.log
[[test one end]]
END: "one"
at log (__tests__/concurrent.test.js:12:29)
at log (__tests__/concurrent.test.js:15:11)
console.log
[[test nine start]]
START "seven"
at log (__tests__/concurrent.test.js:12:29)
at log (__tests__/concurrent.test.js:15:11)
console.log
[[test six end]]
END: "two"
at log (__tests__/concurrent.test.js:12:29)
at log (__tests__/concurrent.test.js:15:11)
console.log
[[test ten (fails) start]]
START "eight"
at log (__tests__/concurrent.test.js:12:29)
at log (__tests__/concurrent.test.js:15:11)
console.log
[[test eight end]]
END: "four"
at log (__tests__/concurrent.test.js:12:29)
at log (__tests__/concurrent.test.js:15:11)
console.log
[[test nine end]]
START "nine"
at log (__tests__/concurrent.test.js:12:29)
at log (__tests__/concurrent.test.js:15:11)
console.log
[[test five end]]
END: "nine"
at log (__tests__/concurrent.test.js:12:29)
at log (__tests__/concurrent.test.js:15:11)
console.log
[[afterAll]]
START "ten"
at log (__tests__/concurrent.test.js:12:29)
at log (__tests__/concurrent.test.js:15:11)
console.log
END: "five"
at log (__tests__/concurrent.test.js:15:11)
console.log
END: "six"
at log (__tests__/concurrent.test.js:15:11)
console.log
END: "seven"
at log (__tests__/concurrent.test.js:15:11)
console.log
END: "ten"
at log (__tests__/concurrent.test.js:15:11)
console.log
END: "eight"
at log (__tests__/concurrent.test.js:15:11)
console.log
afterAll
at log (__tests__/concurrent.test.js:15:11)
"
`;

exports[`with only runs the tests in the correct order 1`] = `
" console.log
beforeAll
at log (__tests__/concurrent-only.test.js:15:11)
console.log
START "four"
at log (__tests__/concurrent-only.test.js:15:11)
console.log
START "six"
at log (__tests__/concurrent-only.test.js:15:11)
console.log
START "nine"
at log (__tests__/concurrent-only.test.js:15:11)
console.log
END: "nine"
at log (__tests__/concurrent-only.test.js:15:11)
console.log
END: "six"
at log (__tests__/concurrent-only.test.js:15:11)
console.log
END: "four"
at log (__tests__/concurrent-only.test.js:15:11)
console.log
afterAll
at log (__tests__/concurrent-only.test.js:15:11)
"
`;

exports[`with skip runs the tests in the correct order 1`] = `
" console.log
beforeAll
at log (__tests__/concurrent-skip.test.js:15:11)
console.log
START "one"
at log (__tests__/concurrent-skip.test.js:15:11)
console.log
START "two"
at log (__tests__/concurrent-skip.test.js:15:11)
console.log
START "four"
at log (__tests__/concurrent-skip.test.js:15:11)
console.log
START "seven"
at log (__tests__/concurrent-skip.test.js:15:11)
console.log
START "eight"
at log (__tests__/concurrent-skip.test.js:15:11)
console.log
END: "one"
at log (__tests__/concurrent-skip.test.js:15:11)
console.log
START "ten"
at log (__tests__/concurrent-skip.test.js:15:11)
console.log
END: "two"
at log (__tests__/concurrent-skip.test.js:15:11)
console.log
END: "seven"
at log (__tests__/concurrent-skip.test.js:15:11)
console.log
END: "four"
at log (__tests__/concurrent-skip.test.js:15:11)
console.log
END: "eight"
at log (__tests__/concurrent-skip.test.js:15:11)
console.log
END: "ten"
at log (__tests__/concurrent-skip.test.js:15:11)
console.log
afterAll
at log (__tests__/concurrent-skip.test.js:15:11)
"
`;
62 changes: 53 additions & 9 deletions e2e/__tests__/circusConcurrent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,65 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import exp = require('constants');
import {skipSuiteOnJasmine} from '@jest/test-utils';
import runJest, {json as runWithJson} from '../runJest';

skipSuiteOnJasmine();

it('runs the correct number of tests', () => {
const {json} = runWithJson('circus-concurrent', ['concurrent.test.js']);
describe('all passing', () => {
it('runs the correct number of tests', () => {
const {json, exitCode} = runWithJson('circus-concurrent', [
'concurrent.test.js',
]);

expect(json.numTotalTests).toBe(10);
expect(json.numPassedTests).toBe(6);
expect(json.numFailedTests).toBe(2);
expect(json.numPendingTests).toBe(2);
expect(exitCode).toBe(0);
expect(json.numTotalTests).toBe(10);
expect(json.numPassedTests).toBe(10);
expect(json.numFailedTests).toBe(0);
expect(json.numPendingTests).toBe(0);
});

it('runs the tests in the correct order', () => {
const {stdout} = runJest('circus-concurrent', ['concurrent.test.js']);
expect(stdout).toMatchSnapshot();

Check failure on line 28 in e2e/__tests__/circusConcurrent.test.ts

View workflow job for this annotation

GitHub Actions / Ubuntu with shard 3/4 / Node v16.x

all passing › runs the tests in the correct order

expect(received).toMatchSnapshot() Snapshot name: `all passing runs the tests in the correct order 1` - Snapshot - 2 + Received + 2 @@ -87,16 +87,16 @@ END: "six" at log (__tests__/concurrent.test.js:15:11) console.log - END: "seven" + END: "ten" at log (__tests__/concurrent.test.js:15:11) console.log - END: "ten" + END: "seven" at log (__tests__/concurrent.test.js:15:11) console.log END: "eight" at Object.toMatchSnapshot (e2e/__tests__/circusConcurrent.test.ts:28:20)

Check failure on line 28 in e2e/__tests__/circusConcurrent.test.ts

View workflow job for this annotation

GitHub Actions / Windows with shard 3/4 / Node v18.x

all passing › runs the tests in the correct order

expect(received).toMatchSnapshot() Snapshot name: `all passing runs the tests in the correct order 1` - Snapshot - 2 + Received + 2 @@ -92,16 +92,16 @@ END: "seven" at log (__tests__/concurrent.test.js:15:11) console.log - END: "ten" + END: "eight" at log (__tests__/concurrent.test.js:15:11) console.log - END: "eight" + END: "ten" at log (__tests__/concurrent.test.js:15:11) console.log afterAll at Object.toMatchSnapshot (e2e/__tests__/circusConcurrent.test.ts:28:20)

Check failure on line 28 in e2e/__tests__/circusConcurrent.test.ts

View workflow job for this annotation

GitHub Actions / Windows with shard 3/4 / Node v22.x

all passing › runs the tests in the correct order

expect(received).toMatchSnapshot() Snapshot name: `all passing runs the tests in the correct order 1` - Snapshot - 4 + Received + 4 @@ -67,21 +67,21 @@ START "nine" at log (__tests__/concurrent.test.js:15:11) console.log - END: "nine" + END: "five" at log (__tests__/concurrent.test.js:15:11) console.log START "ten" at log (__tests__/concurrent.test.js:15:11) console.log - END: "five" + END: "nine" at log (__tests__/concurrent.test.js:15:11) console.log END: "six" @@ -92,16 +92,16 @@ END: "seven" at log (__tests__/concurrent.test.js:15:11) console.log - END: "ten" + END: "eight" at log (__tests__/concurrent.test.js:15:11) console.log - END: "eight" + END: "ten" at log (__tests__/concurrent.test.js:15:11) console.log afterAll at Object.toMatchSnapshot (e2e/__tests__/circusConcurrent.test.ts:28:20)
});
});

it('runs the tests in the correct order', () => {
const {stdout} = runJest('circus-concurrent', ['concurrent.test.js']);
expect(stdout).toMatchSnapshot();
describe('with skip', () => {
it('runs the correct number of tests', () => {
const {json, exitCode} = runWithJson('circus-concurrent', [
'concurrent-skip.test.js',
]);

expect(exitCode).toBe(0);
expect(json.numTotalTests).toBe(10);
expect(json.numPassedTests).toBe(6);
expect(json.numFailedTests).toBe(0);
expect(json.numPendingTests).toBe(4);
});

it('runs the tests in the correct order', () => {
const {stdout} = runJest('circus-concurrent', ['concurrent-skip.test.js']);
expect(stdout).toMatchSnapshot();
});
});

describe('with only', () => {
it('runs the correct number of tests', () => {
const {json, exitCode} = runWithJson('circus-concurrent', [
'concurrent-only.test.js',
]);

expect(exitCode).toBe(0);
expect(json.numTotalTests).toBe(10);
expect(json.numPassedTests).toBe(3);
expect(json.numFailedTests).toBe(0);
expect(json.numPendingTests).toBe(7);
});

it('runs the tests in the correct order', () => {
const {stdout} = runJest('circus-concurrent', ['concurrent-only.test.js']);
expect(stdout).toMatchSnapshot();
});
});
Loading

0 comments on commit 99ada77

Please sign in to comment.