Skip to content

test_runner: ensure proper teardown when tests run without isolation #57394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/internal/test_runner/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@ function run(options = kEmptyObject) {
finishBootstrap();
root.processPendingSubtests();
};
teardown = () => root.harness.teardown();
}
}

Expand Down
35 changes: 35 additions & 0 deletions test/parallel/test-runner-run.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,41 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
assert.strictEqual(diagnostics.includes(entry), true);
}
});

it('should report immediately without waiting for beforeExit event when isolation is none', (t) => {
t.plan(1, { wait: 5_000 });
const events = [];
const expectedEvents = [
'test:enqueue',
'test:dequeue',
'test:complete',
'test:start',
'test:pass',
'test:plan',
'test:diagnostic',
'test:diagnostic',
'test:diagnostic',
'test:diagnostic',
'test:diagnostic',
'test:diagnostic',
'test:diagnostic',
'test:diagnostic',
'test:summary',
];

const stream = run({
isolation: 'none',
files: [fixtures.path('test-runner', 'default-behavior', 'index.test.js')],
});

stream.on('data', (event) => {
events.push(event);
});

stream.on('end', () => {
t.assert.deepStrictEqual(events.map(({ type }) => type), expectedEvents);
});
});
});

describe('forceExit', () => {
Expand Down
Loading