Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: remove interval and give more time to unsync #55006

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions test/parallel/test-runner-watch-mode-complex.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import * as common from '../common/index.mjs';
import { describe, it } from 'node:test';
import assert from 'node:assert';
import { spawn } from 'node:child_process';
import { writeFileSync, unlinkSync } from 'node:fs';
import { writeFile, unlink } from 'node:fs/promises';
import { setTimeout } from 'node:timers/promises';
import util from 'internal/util';
import tmpdir from '../common/tmpdir.js';

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

Object.entries(fixtureContent)
.forEach(([file, content]) => writeFileSync(fixturePaths[file], content));
async function setupFixtures() {
return Promise.all(Object.entries(fixtureContent)
.map(([file, content]) => writeFile(fixturePaths[file], content, { flush: true })));
}

await setupFixtures();
pmarchini marked this conversation as resolved.
Show resolved Hide resolved

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

const content = fixtureContent['dependency.mjs'];
const path = fixturePaths['dependency.mjs'];
const interval = setInterval(() => writeFileSync(path, content), common.platformTimeout(1000));
await writeFile(path, content, { flush: true });
await setTimeout(common.platformTimeout(1000));
await ran2.promise;
runs.push(currentRun);
currentRun = '';
clearInterval(interval);
child.kill();

assert.strictEqual(runs.length, 2);
Expand Down
Loading