Skip to content

Commit dd7af59

Browse files
committed
test_runner: ensure proper teardown when tests run without isolation
1 parent 9df0ff7 commit dd7af59

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

lib/internal/test_runner/runner.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@ function run(options = kEmptyObject) {
797797
finishBootstrap();
798798
root.processPendingSubtests();
799799
};
800+
teardown = () => root.harness.teardown();
800801
}
801802
}
802803

test/parallel/test-runner-run.mjs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,41 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
629629
assert.strictEqual(diagnostics.includes(entry), true);
630630
}
631631
});
632+
633+
it('should report immediately without waiting for beforeExit event when isolation is none', (t) => {
634+
t.plan(1, { wait: 5_000 });
635+
const events = [];
636+
const expectedEvents = [
637+
'test:enqueue',
638+
'test:dequeue',
639+
'test:complete',
640+
'test:start',
641+
'test:pass',
642+
'test:plan',
643+
'test:diagnostic',
644+
'test:diagnostic',
645+
'test:diagnostic',
646+
'test:diagnostic',
647+
'test:diagnostic',
648+
'test:diagnostic',
649+
'test:diagnostic',
650+
'test:diagnostic',
651+
'test:summary',
652+
];
653+
654+
const stream = run({
655+
isolation: 'none',
656+
files: [fixtures.path('test-runner', 'default-behavior', 'index.test.js')],
657+
});
658+
659+
stream.on('data', (event) => {
660+
events.push(event);
661+
});
662+
663+
stream.on('end', () => {
664+
t.assert.deepStrictEqual(events.map(({ type }) => type), expectedEvents);
665+
});
666+
});
632667
});
633668

634669
describe('forceExit', () => {

0 commit comments

Comments
 (0)