Skip to content

Commit 98ff615

Browse files
pmarchinitargos
authored andcommitted
test: add runner watch mode isolation tests
PR-URL: #54888 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent d7c708a commit 98ff615

File tree

1 file changed

+37
-27
lines changed

1 file changed

+37
-27
lines changed

test/parallel/test-runner-watch-mode.mjs

+37-27
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ async function testWatch({
4242
file,
4343
action = 'update',
4444
fileToCreate,
45+
isolation,
4546
}) {
4647
const ran1 = util.createDeferredPromise();
4748
const ran2 = util.createDeferredPromise();
4849
const child = spawn(process.execPath,
4950
['--watch', '--test', '--test-reporter=spec',
51+
isolation ? `--experimental-test-isolation=${isolation}` : '',
5052
file ? fixturePaths[file] : undefined].filter(Boolean),
5153
{ encoding: 'utf8', stdio: 'pipe', cwd: tmpdir.path });
5254
let stdout = '';
@@ -166,31 +168,39 @@ async function testWatch({
166168

167169
describe('test runner watch mode', () => {
168170
beforeEach(refresh);
169-
it('should run tests repeatedly', async () => {
170-
await testWatch({ file: 'test.js', fileToUpdate: 'test.js' });
171-
});
172-
173-
it('should run tests with dependency repeatedly', async () => {
174-
await testWatch({ file: 'test.js', fileToUpdate: 'dependency.js' });
175-
});
176-
177-
it('should run tests with ESM dependency', async () => {
178-
await testWatch({ file: 'test.js', fileToUpdate: 'dependency.mjs' });
179-
});
180-
181-
it('should support running tests without a file', async () => {
182-
await testWatch({ fileToUpdate: 'test.js' });
183-
});
184-
185-
it('should support a watched test file rename', async () => {
186-
await testWatch({ fileToUpdate: 'test.js', action: 'rename' });
187-
});
188-
189-
it('should not throw when delete a watched test file', async () => {
190-
await testWatch({ fileToUpdate: 'test.js', action: 'delete' });
191-
});
192-
193-
it('should run new tests when a new file is created in the watched directory', async () => {
194-
await testWatch({ action: 'create', fileToCreate: 'new-test-file.test.js' });
195-
});
171+
for (const isolation of ['none', 'process']) {
172+
describe(`isolation: ${isolation}`, () => {
173+
it('should run tests repeatedly', async () => {
174+
await testWatch({ file: 'test.js', fileToUpdate: 'test.js', isolation });
175+
});
176+
177+
it('should run tests with dependency repeatedly', async () => {
178+
await testWatch({ file: 'test.js', fileToUpdate: 'dependency.js', isolation });
179+
});
180+
181+
it('should run tests with ESM dependency', async () => {
182+
await testWatch({ file: 'test.js', fileToUpdate: 'dependency.mjs', isolation });
183+
});
184+
185+
it('should support running tests without a file', async () => {
186+
await testWatch({ fileToUpdate: 'test.js', isolation });
187+
});
188+
189+
it('should support a watched test file rename', async () => {
190+
await testWatch({ fileToUpdate: 'test.js', action: 'rename', isolation });
191+
});
192+
193+
it('should not throw when delete a watched test file', async () => {
194+
await testWatch({ fileToUpdate: 'test.js', action: 'delete', isolation });
195+
});
196+
197+
it('should run new tests when a new file is created in the watched directory', {
198+
todo: isolation === 'none' ?
199+
'This test is failing when isolation is set to none and must be fixed' :
200+
undefined,
201+
}, async () => {
202+
await testWatch({ action: 'create', fileToCreate: 'new-test-file.test.js', isolation });
203+
});
204+
});
205+
}
196206
});

0 commit comments

Comments
 (0)