|
1 | 1 | // Flags: --expose-internals |
2 | 2 | import * as common from '../common/index.mjs'; |
3 | 3 | import { describe, it } from 'node:test'; |
| 4 | +import assert from 'node:assert'; |
4 | 5 | import { spawn } from 'node:child_process'; |
5 | 6 | import { writeFileSync } from 'node:fs'; |
6 | 7 | import util from 'internal/util'; |
@@ -36,21 +37,33 @@ async function testWatch({ fileToUpdate, file }) { |
36 | 37 | ['--watch', '--test', file ? fixturePaths[file] : undefined].filter(Boolean), |
37 | 38 | { encoding: 'utf8', stdio: 'pipe', cwd: tmpdir.path }); |
38 | 39 | let stdout = ''; |
| 40 | + let currentRun = ''; |
| 41 | + const runs = []; |
39 | 42 |
|
40 | 43 | child.stdout.on('data', (data) => { |
41 | 44 | stdout += data.toString(); |
42 | | - const testRuns = stdout.match(/ - test has ran/g); |
| 45 | + currentRun += data.toString(); |
| 46 | + const testRuns = stdout.match(/# duration_ms\s\d+/g); |
43 | 47 | if (testRuns?.length >= 1) ran1.resolve(); |
44 | 48 | if (testRuns?.length >= 2) ran2.resolve(); |
45 | 49 | }); |
46 | 50 |
|
47 | 51 | await ran1.promise; |
| 52 | + runs.push(currentRun); |
| 53 | + currentRun = ''; |
48 | 54 | const content = fixtureContent[fileToUpdate]; |
49 | 55 | const path = fixturePaths[fileToUpdate]; |
50 | 56 | const interval = setInterval(() => writeFileSync(path, content), common.platformTimeout(1000)); |
51 | 57 | await ran2.promise; |
| 58 | + runs.push(currentRun); |
52 | 59 | clearInterval(interval); |
53 | 60 | child.kill(); |
| 61 | + for (const run of runs) { |
| 62 | + assert.match(run, /# tests 1/); |
| 63 | + assert.match(run, /# pass 1/); |
| 64 | + assert.match(run, /# fail 0/); |
| 65 | + assert.match(run, /# cancelled 0/); |
| 66 | + } |
54 | 67 | } |
55 | 68 |
|
56 | 69 | describe('test runner watch mode', () => { |
|
0 commit comments