From 37654feea471ec83c566fa9af557b54a72879fde Mon Sep 17 00:00:00 2001 From: Pietro Marchini Date: Sun, 15 Sep 2024 10:46:24 +0200 Subject: [PATCH 1/3] test: add runner watch mode isolation tests --- test/parallel/test-runner-watch-mode.mjs | 45 ++++++++++++++---------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/test/parallel/test-runner-watch-mode.mjs b/test/parallel/test-runner-watch-mode.mjs index 4c059f0a27040e..cfb50b451df6b7 100644 --- a/test/parallel/test-runner-watch-mode.mjs +++ b/test/parallel/test-runner-watch-mode.mjs @@ -42,11 +42,13 @@ async function testWatch({ file, action = 'update', fileToCreate, + isolation, }) { const ran1 = util.createDeferredPromise(); const ran2 = util.createDeferredPromise(); const child = spawn(process.execPath, ['--watch', '--test', '--test-reporter=spec', + isolation ? `--experimental-test-isolation=${isolation}` : '', file ? fixturePaths[file] : undefined].filter(Boolean), { encoding: 'utf8', stdio: 'pipe', cwd: tmpdir.path }); let stdout = ''; @@ -166,31 +168,38 @@ async function testWatch({ describe('test runner watch mode', () => { beforeEach(refresh); - it('should run tests repeatedly', async () => { - await testWatch({ file: 'test.js', fileToUpdate: 'test.js' }); - }); + for (const isolation of ['none', 'process']) { + describe(`isolation: ${isolation}`, () => { + it('should run tests repeatedly', async () => { + await testWatch({ file: 'test.js', fileToUpdate: 'test.js', isolation }); + }); - it('should run tests with dependency repeatedly', async () => { - await testWatch({ file: 'test.js', fileToUpdate: 'dependency.js' }); - }); + it('should run tests with dependency repeatedly', async () => { + await testWatch({ file: 'test.js', fileToUpdate: 'dependency.js', isolation }); + }); - it('should run tests with ESM dependency', async () => { - await testWatch({ file: 'test.js', fileToUpdate: 'dependency.mjs' }); - }); + it('should run tests with ESM dependency', async () => { + await testWatch({ file: 'test.js', fileToUpdate: 'dependency.mjs', isolation }); + }); - it('should support running tests without a file', async () => { - await testWatch({ fileToUpdate: 'test.js' }); - }); + it('should support running tests without a file', async () => { + await testWatch({ fileToUpdate: 'test.js', isolation }); + }); - it('should support a watched test file rename', async () => { - await testWatch({ fileToUpdate: 'test.js', action: 'rename' }); - }); + it('should support a watched test file rename', async () => { + await testWatch({ fileToUpdate: 'test.js', action: 'rename', isolation }); + }); it('should not throw when delete a watched test file', async () => { await testWatch({ fileToUpdate: 'test.js', action: 'delete' }); }); - it('should run new tests when a new file is created in the watched directory', async () => { - await testWatch({ action: 'create', fileToCreate: 'new-test-file.test.js' }); - }); + if (isolation !== 'none') { + // This test is failing if isolation is set to none + it('should run new tests when a new file is created in the watched directory', async () => { + await testWatch({ action: 'create', fileToCreate: 'new-test-file.test.js', isolation }); + }); + } + }); + } }); From dbb8292737b0449338d67a66200305408a14e6a8 Mon Sep 17 00:00:00 2001 From: Pietro Marchini Date: Sun, 15 Sep 2024 10:46:36 +0200 Subject: [PATCH 2/3] test: remove unused skip --- test/parallel/test-runner-watch-mode.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-runner-watch-mode.mjs b/test/parallel/test-runner-watch-mode.mjs index cfb50b451df6b7..6bbb65a81a50c0 100644 --- a/test/parallel/test-runner-watch-mode.mjs +++ b/test/parallel/test-runner-watch-mode.mjs @@ -190,9 +190,9 @@ describe('test runner watch mode', () => { await testWatch({ fileToUpdate: 'test.js', action: 'rename', isolation }); }); - it('should not throw when delete a watched test file', async () => { - await testWatch({ fileToUpdate: 'test.js', action: 'delete' }); - }); + it('should not throw when delete a watched test file', async () => { + await testWatch({ fileToUpdate: 'test.js', action: 'delete', isolation }); + }); if (isolation !== 'none') { // This test is failing if isolation is set to none From 0eab8529cfdcfae8e482fc43286c5582a8c6981e Mon Sep 17 00:00:00 2001 From: Pietro Marchini Date: Sun, 15 Sep 2024 10:46:36 +0200 Subject: [PATCH 3/3] test: add todo test --- test/parallel/test-runner-watch-mode.mjs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-runner-watch-mode.mjs b/test/parallel/test-runner-watch-mode.mjs index 6bbb65a81a50c0..b6fa0a2fe0f131 100644 --- a/test/parallel/test-runner-watch-mode.mjs +++ b/test/parallel/test-runner-watch-mode.mjs @@ -194,12 +194,13 @@ describe('test runner watch mode', () => { await testWatch({ fileToUpdate: 'test.js', action: 'delete', isolation }); }); - if (isolation !== 'none') { - // This test is failing if isolation is set to none - it('should run new tests when a new file is created in the watched directory', async () => { - await testWatch({ action: 'create', fileToCreate: 'new-test-file.test.js', isolation }); - }); - } + it('should run new tests when a new file is created in the watched directory', { + todo: isolation === 'none' ? + 'This test is failing when isolation is set to none and must be fixed' : + undefined, + }, async () => { + await testWatch({ action: 'create', fileToCreate: 'new-test-file.test.js', isolation }); + }); }); } });