Skip to content

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

Open
pmarchini wants to merge 1 commit into
nodejs:mainfrom
pmarchini:test_runner/57234
Open

test_runner: ensure proper teardown when tests run without isolation#57394
pmarchini wants to merge 1 commit into
nodejs:mainfrom
pmarchini:test_runner/57234

Conversation

@pmarchini

Copy link
Copy Markdown
Member

This should address #57234.

Adding the teardown in case of isolation: none addresses this specific issue, and I see no potential negative effects in having it.

@cjihrig, was there a reason why we avoided it in the first place?

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/test_runner

@pmarchini
pmarchini requested a review from cjihrig March 9, 2025 22:49
@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Mar 9, 2025
@codecov

codecov Bot commented Mar 9, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.23%. Comparing base (9df0ff7) to head (dd7af59).
⚠️ Report is 3924 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57394      +/-   ##
==========================================
- Coverage   90.23%   90.23%   -0.01%     
==========================================
  Files         630      630              
  Lines      185200   185214      +14     
  Branches    36233    36243      +10     
==========================================
+ Hits       167108   167120      +12     
- Misses      11056    11057       +1     
- Partials     7036     7037       +1     
Files with missing lines Coverage Δ
lib/internal/test_runner/runner.js 89.52% <100.00%> (+0.01%) ⬆️

... and 22 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pmarchini

Copy link
Copy Markdown
Member Author

These changes have broken the following test:

{
const child = spawnSync(process.execPath, [
'--test',
'--test-isolation=none',
fixtures.path('test-runner', 'async-error-in-test-hook.mjs'),
]);
const stdout = child.stdout.toString();
assert.match(stdout, /Error: Test hook "before" at .+async-error-in-test-hook\.mjs:3:1 generated asynchronous activity after the test ended/m);
assert.match(stdout, /Error: Test hook "beforeEach" at .+async-error-in-test-hook\.mjs:9:1 generated asynchronous activity after the test ended/m);
assert.match(stdout, /Error: Test hook "after" at .+async-error-in-test-hook\.mjs:15:1 generated asynchronous activity after the test ended/m);
assert.match(stdout, /Error: Test hook "afterEach" at .+async-error-in-test-hook\.mjs:21:1 generated asynchronous activity after the test ended/m);
assert.match(stdout, /pass 1$/m);
assert.match(stdout, /fail 0$/m);
assert.match(stdout, /cancelled 0$/m);
assert.strictEqual(child.status, 1);
assert.strictEqual(child.signal, null);
}

I'm taking a look!

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@inoway46

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been marked as stale due to 90 days of inactivity.
It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

@github-actions github-actions Bot added the stale label Jul 28, 2026
@inukshuk

Copy link
Copy Markdown

I'm using the test-runner in Electron, where usually isolation=none is the preferred way to use it (especially in the renderer process). It would be great to have this merged. Currently, we have to jump through hoops, like emitting a fake 'beforeExit' after the tests to get the runner to shut down in isolation.

#62269 is also related.

@pmarchini

Copy link
Copy Markdown
Member Author

Hey @inukshuk, I’ll take another look at the issue ASAP.

The PR got stuck due to some unexpected changes in behavior

@github-actions github-actions Bot removed the stale label Jul 29, 2026
@avivkeller avivkeller added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Jul 30, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 30, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@aduh95

aduh95 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

CI is failing

@aduh95 aduh95 removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants