Skip to content

Commit

Permalink
add debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLow committed Feb 25, 2023
1 parent a3aec85 commit 1858728
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/parallel/test-runner-watch-mode.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,22 @@ async function testWatch({ files, fileToUpdate }) {
const ran2 = util.createDeferredPromise();
const child = spawn(process.execPath, ['--watch', '--test', '--no-warnings', ...files], { encoding: 'utf8' });
let stdout = '';

console.log(`${child.pid} [running test]`);
child.stdout.on('data', (data) => {
console.log(data.toString().split(/\r?\n/).map((line) => `${child.pid} [stdout] ${line}`).join('\n'));
stdout += data.toString();
const matches = stdout.match(/test has ran/g);
if (matches?.length >= 1) ran1.resolve();
if (matches?.length >= 2) ran2.resolve();
});

await ran1.promise;
console.log(`${child.pid} [restarting]`);
const interval = setInterval(() => writeFileSync(fileToUpdate, readFileSync(fileToUpdate, 'utf8')), 50);
await ran2.promise;
clearInterval(interval);
console.log(`${child.pid} [done]`);
child.kill();
}

Expand Down

0 comments on commit 1858728

Please sign in to comment.