diff --git a/test/common/watch.js b/test/common/watch.js index 47a906e7754..1831939b5a9 100644 --- a/test/common/watch.js +++ b/test/common/watch.js @@ -60,7 +60,7 @@ async function testRunnerWatch({ ['--watch', '--test', '--test-reporter=spec', isolation ? `--test-isolation=${isolation}` : '', file ? fixturePaths[file] : undefined].filter(Boolean), - { encoding: 'utf8', stdio: ['inherit', 'pipe', 'inherit'], cwd: tmpdir.path }); + { encoding: 'utf8', stdio: 'pipe', cwd: tmpdir.path }); let stdout = ''; let currentRun = ''; const runs = []; diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index bf040bf2ee9..8ac30c58992 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -50,10 +50,6 @@ test-runner-run-watch: PASS, FLAKY # https://github.com/nodejs/node/issues/58353 test-http2-debug: PASS, FLAKY -[$system==linux || $system==win32] -# https://github.com/nodejs/node/issues/49605 -test-runner-watch-mode: PASS,FLAKY - [$system==macos] # https://github.com/nodejs/node/issues/42741 test-http-server-headers-timeout-keepalive: PASS,FLAKY diff --git a/test/parallel/test-runner-watch-mode.mjs b/test/parallel/test-runner-watch-mode.mjs deleted file mode 100644 index d6931ef9a79..00000000000 --- a/test/parallel/test-runner-watch-mode.mjs +++ /dev/null @@ -1,44 +0,0 @@ -import '../common/index.mjs'; -import { skipIfNoWatch, refreshForTestRunnerWatch, testRunnerWatch } from '../common/watch.js'; -import { describe, it, beforeEach } from 'node:test'; - -skipIfNoWatch(); - -describe('test runner watch mode', () => { - beforeEach(refreshForTestRunnerWatch); - for (const isolation of ['none', 'process']) { - describe(`isolation: ${isolation}`, () => { - it('should run tests repeatedly', async () => { - await testRunnerWatch({ file: 'test.js', fileToUpdate: 'test.js', isolation }); - }); - - it('should run tests with dependency repeatedly', async () => { - await testRunnerWatch({ file: 'test.js', fileToUpdate: 'dependency.js', isolation }); - }); - - it('should run tests with ESM dependency', async () => { - await testRunnerWatch({ file: 'test.js', fileToUpdate: 'dependency.mjs', isolation }); - }); - - it('should support running tests without a file', async () => { - await testRunnerWatch({ fileToUpdate: 'test.js', isolation }); - }); - - it('should support a watched test file rename', async () => { - await testRunnerWatch({ fileToUpdate: 'test.js', action: 'rename', isolation }); - }); - - it('should not throw when delete a watched test file', async () => { - await testRunnerWatch({ fileToUpdate: 'test.js', action: 'delete', 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 testRunnerWatch({ action: 'create', fileToCreate: 'new-test-file.test.js', isolation }); - }); - }); - } -}); diff --git a/test/test-runner/test-runner.status b/test/test-runner/test-runner.status index 65ae96eb9e3..e8b4ff2d322 100644 --- a/test/test-runner/test-runner.status +++ b/test/test-runner/test-runner.status @@ -5,3 +5,7 @@ prefix test-runner # sample-test : PASS,FLAKY [true] # This section applies to all platforms + +# https://github.com/nodejs/node/pull/54888#issuecomment-2351128116 +# TODO(pmarchini): This test is failing when isolation is set to none and must be fixed. +test-watch-create-isolation-none: SKIP diff --git a/test/test-runner/test-watch-create-isolation-none.mjs b/test/test-runner/test-watch-create-isolation-none.mjs new file mode 100644 index 00000000000..c7035ea63af --- /dev/null +++ b/test/test-runner/test-watch-create-isolation-none.mjs @@ -0,0 +1,8 @@ +// Test --test --watch --test-isolation=none runs tests when a new file is created in the watched directory +import '../common/index.mjs'; +import { skipIfNoWatch, refreshForTestRunnerWatch, testRunnerWatch } from '../common/watch.js'; + +skipIfNoWatch(); +refreshForTestRunnerWatch(); + +await testRunnerWatch({ action: 'create', fileToCreate: 'new-test-file.test.js', isolation: 'none' }); diff --git a/test/test-runner/test-watch-create-isolation-process.mjs b/test/test-runner/test-watch-create-isolation-process.mjs new file mode 100644 index 00000000000..d1eaa9667d2 --- /dev/null +++ b/test/test-runner/test-watch-create-isolation-process.mjs @@ -0,0 +1,8 @@ +// Test --test --watch --test-isolation=process runs tests when a new file is created in the watched directory +import '../common/index.mjs'; +import { skipIfNoWatch, refreshForTestRunnerWatch, testRunnerWatch } from '../common/watch.js'; + +skipIfNoWatch(); +refreshForTestRunnerWatch(); + +await testRunnerWatch({ action: 'create', fileToCreate: 'new-test-file.test.js', isolation: 'process' }); diff --git a/test/test-runner/test-watch-delete-isolation-none.mjs b/test/test-runner/test-watch-delete-isolation-none.mjs new file mode 100644 index 00000000000..210d2a87f82 --- /dev/null +++ b/test/test-runner/test-watch-delete-isolation-none.mjs @@ -0,0 +1,8 @@ +// Test --test --watch --test-isolation=none does not throw when deleting a watched test file +import '../common/index.mjs'; +import { skipIfNoWatch, refreshForTestRunnerWatch, testRunnerWatch } from '../common/watch.js'; + +skipIfNoWatch(); +refreshForTestRunnerWatch(); + +await testRunnerWatch({ fileToUpdate: 'test.js', action: 'delete', isolation: 'none' }); diff --git a/test/test-runner/test-watch-delete-isolation-process.mjs b/test/test-runner/test-watch-delete-isolation-process.mjs new file mode 100644 index 00000000000..d09b84caf53 --- /dev/null +++ b/test/test-runner/test-watch-delete-isolation-process.mjs @@ -0,0 +1,8 @@ +// Test --test --watch --test-isolation=process does not throw when deleting a watched test file +import '../common/index.mjs'; +import { skipIfNoWatch, refreshForTestRunnerWatch, testRunnerWatch } from '../common/watch.js'; + +skipIfNoWatch(); +refreshForTestRunnerWatch(); + +await testRunnerWatch({ fileToUpdate: 'test.js', action: 'delete', isolation: 'process' }); diff --git a/test/test-runner/test-watch-dependency-isolation-none.mjs b/test/test-runner/test-watch-dependency-isolation-none.mjs new file mode 100644 index 00000000000..7171a334ce0 --- /dev/null +++ b/test/test-runner/test-watch-dependency-isolation-none.mjs @@ -0,0 +1,8 @@ +// Test --test --watch --test-isolation=none runs tests with dependency repeatedly +import '../common/index.mjs'; +import { skipIfNoWatch, refreshForTestRunnerWatch, testRunnerWatch } from '../common/watch.js'; + +skipIfNoWatch(); +refreshForTestRunnerWatch(); + +await testRunnerWatch({ file: 'test.js', fileToUpdate: 'dependency.js', isolation: 'none' }); diff --git a/test/test-runner/test-watch-dependency-isolation-process.mjs b/test/test-runner/test-watch-dependency-isolation-process.mjs new file mode 100644 index 00000000000..25b8d00f3b0 --- /dev/null +++ b/test/test-runner/test-watch-dependency-isolation-process.mjs @@ -0,0 +1,8 @@ +// Test --test --watch --test-isolation=process runs tests with dependency repeatedly +import '../common/index.mjs'; +import { skipIfNoWatch, refreshForTestRunnerWatch, testRunnerWatch } from '../common/watch.js'; + +skipIfNoWatch(); +refreshForTestRunnerWatch(); + +await testRunnerWatch({ file: 'test.js', fileToUpdate: 'dependency.js', isolation: 'process' }); diff --git a/test/test-runner/test-watch-esm-dependency-isolation-none.mjs b/test/test-runner/test-watch-esm-dependency-isolation-none.mjs new file mode 100644 index 00000000000..d066bd90d74 --- /dev/null +++ b/test/test-runner/test-watch-esm-dependency-isolation-none.mjs @@ -0,0 +1,8 @@ +// Test --test --watch --test-isolation=none runs tests with ESM dependency +import '../common/index.mjs'; +import { skipIfNoWatch, refreshForTestRunnerWatch, testRunnerWatch } from '../common/watch.js'; + +skipIfNoWatch(); +refreshForTestRunnerWatch(); + +await testRunnerWatch({ file: 'test.js', fileToUpdate: 'dependency.mjs', isolation: 'none' }); diff --git a/test/test-runner/test-watch-esm-dependency-isolation-process.mjs b/test/test-runner/test-watch-esm-dependency-isolation-process.mjs new file mode 100644 index 00000000000..7e0ad48ece0 --- /dev/null +++ b/test/test-runner/test-watch-esm-dependency-isolation-process.mjs @@ -0,0 +1,8 @@ +// Test --test --watch --test-isolation=process runs tests with ESM dependency +import '../common/index.mjs'; +import { skipIfNoWatch, refreshForTestRunnerWatch, testRunnerWatch } from '../common/watch.js'; + +skipIfNoWatch(); +refreshForTestRunnerWatch(); + +await testRunnerWatch({ file: 'test.js', fileToUpdate: 'dependency.mjs', isolation: 'process' }); diff --git a/test/test-runner/test-watch-no-file-isolation-none.mjs b/test/test-runner/test-watch-no-file-isolation-none.mjs new file mode 100644 index 00000000000..ebf14d828a3 --- /dev/null +++ b/test/test-runner/test-watch-no-file-isolation-none.mjs @@ -0,0 +1,8 @@ +// Test --test --watch --test-isolation=none runs tests without a file argument +import '../common/index.mjs'; +import { skipIfNoWatch, refreshForTestRunnerWatch, testRunnerWatch } from '../common/watch.js'; + +skipIfNoWatch(); +refreshForTestRunnerWatch(); + +await testRunnerWatch({ fileToUpdate: 'test.js', isolation: 'none' }); diff --git a/test/test-runner/test-watch-no-file-isolation-process.mjs b/test/test-runner/test-watch-no-file-isolation-process.mjs new file mode 100644 index 00000000000..76991b37189 --- /dev/null +++ b/test/test-runner/test-watch-no-file-isolation-process.mjs @@ -0,0 +1,8 @@ +// Test --test --watch --test-isolation=process runs tests without a file argument +import '../common/index.mjs'; +import { skipIfNoWatch, refreshForTestRunnerWatch, testRunnerWatch } from '../common/watch.js'; + +skipIfNoWatch(); +refreshForTestRunnerWatch(); + +await testRunnerWatch({ fileToUpdate: 'test.js', isolation: 'process' }); diff --git a/test/test-runner/test-watch-rename-isolation-none.mjs b/test/test-runner/test-watch-rename-isolation-none.mjs new file mode 100644 index 00000000000..d125b33ce83 --- /dev/null +++ b/test/test-runner/test-watch-rename-isolation-none.mjs @@ -0,0 +1,8 @@ +// Test --test --watch --test-isolation=none handles a watched test file rename +import '../common/index.mjs'; +import { skipIfNoWatch, refreshForTestRunnerWatch, testRunnerWatch } from '../common/watch.js'; + +skipIfNoWatch(); +refreshForTestRunnerWatch(); + +await testRunnerWatch({ fileToUpdate: 'test.js', action: 'rename', isolation: 'none' }); diff --git a/test/test-runner/test-watch-rename-isolation-process.mjs b/test/test-runner/test-watch-rename-isolation-process.mjs new file mode 100644 index 00000000000..e784831a33b --- /dev/null +++ b/test/test-runner/test-watch-rename-isolation-process.mjs @@ -0,0 +1,8 @@ +// Test --test --watch --test-isolation=process handles a watched test file rename +import '../common/index.mjs'; +import { skipIfNoWatch, refreshForTestRunnerWatch, testRunnerWatch } from '../common/watch.js'; + +skipIfNoWatch(); +refreshForTestRunnerWatch(); + +await testRunnerWatch({ fileToUpdate: 'test.js', action: 'rename', isolation: 'process' }); diff --git a/test/test-runner/test-watch-run-repeatedly-isolation-none.mjs b/test/test-runner/test-watch-run-repeatedly-isolation-none.mjs new file mode 100644 index 00000000000..763f5a3be05 --- /dev/null +++ b/test/test-runner/test-watch-run-repeatedly-isolation-none.mjs @@ -0,0 +1,8 @@ +// Test --test --watch --test-isolation=none runs tests repeatedly +import '../common/index.mjs'; +import { skipIfNoWatch, refreshForTestRunnerWatch, testRunnerWatch } from '../common/watch.js'; + +skipIfNoWatch(); +refreshForTestRunnerWatch(); + +await testRunnerWatch({ file: 'test.js', fileToUpdate: 'test.js', isolation: 'none' }); diff --git a/test/test-runner/test-watch-run-repeatedly-isolation-process.mjs b/test/test-runner/test-watch-run-repeatedly-isolation-process.mjs new file mode 100644 index 00000000000..07719cfd777 --- /dev/null +++ b/test/test-runner/test-watch-run-repeatedly-isolation-process.mjs @@ -0,0 +1,8 @@ +// Test --test --watch --test-isolation=process runs tests repeatedly +import '../common/index.mjs'; +import { skipIfNoWatch, refreshForTestRunnerWatch, testRunnerWatch } from '../common/watch.js'; + +skipIfNoWatch(); +refreshForTestRunnerWatch(); + +await testRunnerWatch({ file: 'test.js', fileToUpdate: 'test.js', isolation: 'process' });