Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 80da599

Browse filesBrowse files
pmarchinitargos
authored andcommitted
test: remove interval and give more time to unsync
PR-URL: #55006 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
1 parent 173464d commit 80da599
Copy full SHA for 80da599

File tree

Expand file treeCollapse file tree

1 file changed

+12
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+12
-6
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-runner-watch-mode-complex.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-runner-watch-mode-complex.mjs
+12-6Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import * as common from '../common/index.mjs';
33
import { describe, it } from 'node:test';
44
import assert from 'node:assert';
55
import { spawn } from 'node:child_process';
6-
import { writeFileSync, unlinkSync } from 'node:fs';
6+
import { writeFile, unlink } from 'node:fs/promises';
7+
import { setTimeout } from 'node:timers/promises';
78
import util from 'internal/util';
89
import tmpdir from '../common/tmpdir.js';
910

@@ -46,8 +47,12 @@ test('test to delete has ran');`,
4647
const fixturePaths = Object.fromEntries(Object.keys(fixtureContent)
4748
.map((file) => [file, tmpdir.resolve(file)]));
4849

49-
Object.entries(fixtureContent)
50-
.forEach(([file, content]) => writeFileSync(fixturePaths[file], content));
50+
async function setupFixtures() {
51+
return Promise.all(Object.entries(fixtureContent)
52+
.map(([file, content]) => writeFile(fixturePaths[file], content, { flush: true })));
53+
}
54+
55+
await setupFixtures();
5156

5257
describe('test runner watch mode with more complex setup', () => {
5358
it('should run tests when a dependency changed after a watched test file being deleted', async () => {
@@ -76,15 +81,16 @@ describe('test runner watch mode with more complex setup', () => {
7681
runs.push(currentRun);
7782
currentRun = '';
7883
const fileToDeletePathLocal = tmpdir.resolve('test-to-delete.mjs');
79-
unlinkSync(fileToDeletePathLocal);
84+
await unlink(fileToDeletePathLocal);
85+
await setTimeout(common.platformTimeout(1000));
8086

8187
const content = fixtureContent['dependency.mjs'];
8288
const path = fixturePaths['dependency.mjs'];
83-
const interval = setInterval(() => writeFileSync(path, content), common.platformTimeout(1000));
89+
await writeFile(path, content, { flush: true });
90+
await setTimeout(common.platformTimeout(1000));
8491
await ran2.promise;
8592
runs.push(currentRun);
8693
currentRun = '';
87-
clearInterval(interval);
8894
child.kill();
8995

9096
assert.strictEqual(runs.length, 2);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.