Skip to content

Commit

Permalink
test: apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarchini committed Sep 22, 2024
1 parent e832333 commit e97c082
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions test/fixtures/test-runner-watch.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ if (values.isolation) {
run({
files,
watch: true,
...(cwd ? { cwd } : {}),
...(isolation ? { isolation } : {}),
cwd,
isolation,
}).compose(tap).pipe(process.stdout);
13 changes: 5 additions & 8 deletions test/parallel/test-runner-watch-mode.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { once } from 'node:events';
import assert from 'node:assert';
import { spawn } from 'node:child_process';
import { writeFileSync, renameSync, unlinkSync } from 'node:fs';
import { setTimeout } from 'node:timers/promises';
import util from 'internal/util';
import tmpdir from '../common/tmpdir.js';

Expand All @@ -29,10 +30,6 @@ import('data:text/javascript,');
test('test has ran');`,
};

function wait(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

function refresh() {
tmpdir.refresh();
fixturePaths = Object.keys(fixtureContent)
Expand Down Expand Up @@ -74,7 +71,7 @@ async function testWatch({
const content = fixtureContent[fileToUpdate];
const path = fixturePaths[fileToUpdate];
writeFileSync(path, content);
await wait(common.platformTimeout(1000));
await setTimeout(common.platformTimeout(1000));
await ran2.promise;
runs.push(currentRun);
child.kill();
Expand All @@ -97,7 +94,7 @@ async function testWatch({
const fileToRenamePath = tmpdir.resolve(fileToUpdate);
const newFileNamePath = tmpdir.resolve(`test-renamed-${fileToUpdate}`);
renameSync(fileToRenamePath, newFileNamePath);
await wait(common.platformTimeout(1000));
await setTimeout(common.platformTimeout(1000));
await ran2.promise;
runs.push(currentRun);
child.kill();
Expand All @@ -119,7 +116,7 @@ async function testWatch({
currentRun = '';
const fileToDeletePath = tmpdir.resolve(fileToUpdate);
unlinkSync(fileToDeletePath);
await wait(common.platformTimeout(2000));
await setTimeout(common.platformTimeout(2000));
ran2.resolve();
runs.push(currentRun);
child.kill();
Expand All @@ -138,7 +135,7 @@ async function testWatch({
currentRun = '';
const newFilePath = tmpdir.resolve(fileToCreate);
writeFileSync(newFilePath, 'module.exports = {};');
await wait(common.platformTimeout(1000));
await setTimeout(common.platformTimeout(1000));
await ran2.promise;
runs.push(currentRun);
child.kill();
Expand Down

0 comments on commit e97c082

Please sign in to comment.