@@ -15,46 +15,74 @@ afterEach(() => rm(stateFile, { force: true })); |
15 | 15 |
|
16 | 16 | const expectedStateFile = [ |
17 | 17 | { |
18 | | - 'test/fixtures/test-runner/rerun.js:17:3': { passed_on_attempt: 0, name: 'ambiguous (expectedAttempts=0)' }, |
19 | 18 | 'test/fixtures/test-runner/rerun.js:9:1': { passed_on_attempt: 0, name: 'ok' }, |
| 19 | + 'test/fixtures/test-runner/rerun.js:17:3': { passed_on_attempt: 0, name: 'ambiguous (expectedAttempts=0)' }, |
| 20 | + 'test/fixtures/test-runner/rerun.js:30:16': { passed_on_attempt: 0, name: '2 levels deep' }, |
| 21 | + 'test/fixtures/test-runner/rerun.js:29:13': { passed_on_attempt: 0, name: 'nested' }, |
| 22 | + 'test/fixtures/test-runner/rerun.js:35:13': { passed_on_attempt: 0, name: 'ok' }, |
| 23 | + 'test/fixtures/test-runner/rerun.js:39:1': { passed_on_attempt: 0, name: 'nested ambiguous (expectedAttempts=0)' }, |
| 24 | + 'test/fixtures/test-runner/rerun.js:30:16:(1)': { passed_on_attempt: 0, name: '2 levels deep' }, |
| 25 | + 'test/fixtures/test-runner/rerun.js:35:13:(1)': { passed_on_attempt: 0, name: 'ok' }, |
20 | 26 | }, |
21 | 27 | { |
| 28 | + 'test/fixtures/test-runner/rerun.js:9:1': { passed_on_attempt: 0, name: 'ok' }, |
22 | 29 | 'test/fixtures/test-runner/rerun.js:17:3': { passed_on_attempt: 0, name: 'ambiguous (expectedAttempts=0)' }, |
23 | 30 | 'test/fixtures/test-runner/rerun.js:17:3:(1)': { passed_on_attempt: 1, name: 'ambiguous (expectedAttempts=1)' }, |
24 | | - 'test/fixtures/test-runner/rerun.js:9:1': { passed_on_attempt: 0, name: 'ok' }, |
| 31 | + 'test/fixtures/test-runner/rerun.js:30:16': { passed_on_attempt: 0, name: '2 levels deep' }, |
| 32 | + 'test/fixtures/test-runner/rerun.js:29:13': { passed_on_attempt: 0, name: 'nested' }, |
| 33 | + 'test/fixtures/test-runner/rerun.js:35:13': { passed_on_attempt: 0, name: 'ok' }, |
| 34 | + 'test/fixtures/test-runner/rerun.js:39:1': { passed_on_attempt: 0, name: 'nested ambiguous (expectedAttempts=0)' }, |
| 35 | + 'test/fixtures/test-runner/rerun.js:30:16:(1)': { passed_on_attempt: 0, name: '2 levels deep' }, |
| 36 | + 'test/fixtures/test-runner/rerun.js:35:13:(1)': { passed_on_attempt: 0, name: 'ok' }, |
25 | 37 | }, |
26 | 38 | { |
| 39 | + 'test/fixtures/test-runner/rerun.js:3:1': { passed_on_attempt: 2, name: 'should fail on first two attempts' }, |
| 40 | + 'test/fixtures/test-runner/rerun.js:9:1': { passed_on_attempt: 0, name: 'ok' }, |
27 | 41 | 'test/fixtures/test-runner/rerun.js:17:3': { passed_on_attempt: 0, name: 'ambiguous (expectedAttempts=0)' }, |
28 | 42 | 'test/fixtures/test-runner/rerun.js:17:3:(1)': { passed_on_attempt: 1, name: 'ambiguous (expectedAttempts=1)' }, |
29 | | - 'test/fixtures/test-runner/rerun.js:9:1': { passed_on_attempt: 0, name: 'ok' }, |
30 | | - 'test/fixtures/test-runner/rerun.js:3:1': { passed_on_attempt: 2, name: 'should fail on first two attempts' }, |
| 43 | + 'test/fixtures/test-runner/rerun.js:30:16': { passed_on_attempt: 0, name: '2 levels deep' }, |
| 44 | + 'test/fixtures/test-runner/rerun.js:29:13': { passed_on_attempt: 0, name: 'nested' }, |
| 45 | + 'test/fixtures/test-runner/rerun.js:35:13': { passed_on_attempt: 0, name: 'ok' }, |
| 46 | + 'test/fixtures/test-runner/rerun.js:39:1': { passed_on_attempt: 0, name: 'nested ambiguous (expectedAttempts=0)' }, |
| 47 | + 'test/fixtures/test-runner/rerun.js:29:13:(1)': { passed_on_attempt: 2, name: 'nested' }, |
| 48 | + 'test/fixtures/test-runner/rerun.js:30:16:(1)': { passed_on_attempt: 0, name: '2 levels deep' }, |
| 49 | + 'test/fixtures/test-runner/rerun.js:35:13:(1)': { passed_on_attempt: 0, name: 'ok' }, |
| 50 | + 'test/fixtures/test-runner/rerun.js:40:1': { passed_on_attempt: 2, name: 'nested ambiguous (expectedAttempts=1)' }, |
31 | 51 | }, |
32 | 52 | ]; |
33 | 53 |
|
34 | | -const getStateFile = async () => JSON.parse((await readFile(stateFile, 'utf8')).replaceAll('\\\\', '/')); |
| 54 | +const getStateFile = async () => { |
| 55 | + const res = JSON.parse((await readFile(stateFile, 'utf8')).replaceAll('\\\\', '/')); |
| 56 | + res.forEach((entry) => { |
| 57 | + for (const item in entry) { |
| 58 | + delete entry[item].children; |
| 59 | + } |
| 60 | + }); |
| 61 | + return res; |
| 62 | +}; |
35 | 63 |
|
36 | 64 | test('test should pass on third rerun', async () => { |
37 | 65 | const args = ['--test-rerun-failures', stateFile, fixture]; |
38 | 66 |
|
39 | 67 | let { code, stdout, signal } = await common.spawnPromisified(process.execPath, args); |
40 | 68 | assert.strictEqual(code, 1); |
41 | 69 | assert.strictEqual(signal, null); |
42 | | - assert.match(stdout, /pass 2/); |
43 | | - assert.match(stdout, /fail 2/); |
| 70 | + assert.match(stdout, /pass 8/); |
| 71 | + assert.match(stdout, /fail 4/); |
44 | 72 | assert.deepStrictEqual(await getStateFile(), expectedStateFile.slice(0, 1)); |
45 | 73 |
|
46 | 74 | ({ code, stdout, signal } = await common.spawnPromisified(process.execPath, args)); |
47 | 75 | assert.strictEqual(code, 1); |
48 | 76 | assert.strictEqual(signal, null); |
49 | | - assert.match(stdout, /pass 3/); |
50 | | - assert.match(stdout, /fail 1/); |
| 77 | + assert.match(stdout, /pass 9/); |
| 78 | + assert.match(stdout, /fail 3/); |
51 | 79 | assert.deepStrictEqual(await getStateFile(), expectedStateFile.slice(0, 2)); |
52 | 80 |
|
53 | 81 |
|
54 | 82 | ({ code, stdout, signal } = await common.spawnPromisified(process.execPath, args)); |
55 | 83 | assert.strictEqual(code, 0); |
56 | 84 | assert.strictEqual(signal, null); |
57 | | - assert.match(stdout, /pass 4/); |
| 85 | + assert.match(stdout, /pass 12/); |
58 | 86 | assert.match(stdout, /fail 0/); |
59 | 87 | assert.deepStrictEqual(await getStateFile(), expectedStateFile); |
60 | 88 | }); |
@@ -65,30 +93,30 @@ test('test should pass on third rerun with `--test`', async () => { |
65 | 93 | let { code, stdout, signal } = await common.spawnPromisified(process.execPath, args); |
66 | 94 | assert.strictEqual(code, 1); |
67 | 95 | assert.strictEqual(signal, null); |
68 | | - assert.match(stdout, /pass 2/); |
69 | | - assert.match(stdout, /fail 2/); |
| 96 | + assert.match(stdout, /pass 8/); |
| 97 | + assert.match(stdout, /fail 4/); |
70 | 98 | assert.deepStrictEqual(await getStateFile(), expectedStateFile.slice(0, 1)); |
71 | 99 |
|
72 | 100 | ({ code, stdout, signal } = await common.spawnPromisified(process.execPath, args)); |
73 | 101 | assert.strictEqual(code, 1); |
74 | 102 | assert.strictEqual(signal, null); |
75 | | - assert.match(stdout, /pass 3/); |
76 | | - assert.match(stdout, /fail 1/); |
| 103 | + assert.match(stdout, /pass 9/); |
| 104 | + assert.match(stdout, /fail 3/); |
77 | 105 | assert.deepStrictEqual(await getStateFile(), expectedStateFile.slice(0, 2)); |
78 | 106 |
|
79 | 107 |
|
80 | 108 | ({ code, stdout, signal } = await common.spawnPromisified(process.execPath, args)); |
81 | 109 | assert.strictEqual(code, 0); |
82 | 110 | assert.strictEqual(signal, null); |
83 | | - assert.match(stdout, /pass 4/); |
| 111 | + assert.match(stdout, /pass 12/); |
84 | 112 | assert.match(stdout, /fail 0/); |
85 | 113 | assert.deepStrictEqual(await getStateFile(), expectedStateFile); |
86 | 114 | }); |
87 | 115 |
|
88 | 116 | test('using `run` api', async () => { |
89 | 117 | let stream = run({ files: [fixture], rerunFailuresFilePath: stateFile }); |
90 | | - stream.on('test:pass', common.mustCall(2)); |
91 | | - stream.on('test:fail', common.mustCall(2)); |
| 118 | + stream.on('test:pass', common.mustCall(8)); |
| 119 | + stream.on('test:fail', common.mustCall(4)); |
92 | 120 |
|
93 | 121 | // eslint-disable-next-line no-unused-vars |
94 | 122 | for await (const _ of stream); |
@@ -97,8 +125,8 @@ test('using `run` api', async () => { |
97 | 125 |
|
98 | 126 |
|
99 | 127 | stream = run({ files: [fixture], rerunFailuresFilePath: stateFile }); |
100 | | - stream.on('test:pass', common.mustCall(3)); |
101 | | - stream.on('test:fail', common.mustCall(1)); |
| 128 | + stream.on('test:pass', common.mustCall(9)); |
| 129 | + stream.on('test:fail', common.mustCall(3)); |
102 | 130 |
|
103 | 131 | // eslint-disable-next-line no-unused-vars |
104 | 132 | for await (const _ of stream); |
@@ -107,7 +135,7 @@ test('using `run` api', async () => { |
107 | 135 |
|
108 | 136 |
|
109 | 137 | stream = run({ files: [fixture], rerunFailuresFilePath: stateFile }); |
110 | | - stream.on('test:pass', common.mustCall(4)); |
| 138 | + stream.on('test:pass', common.mustCall(12)); |
111 | 139 | stream.on('test:fail', common.mustNotCall()); |
112 | 140 |
|
113 | 141 | // eslint-disable-next-line no-unused-vars |
|