Skip to content

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

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

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

Conversation

@pmarchini
Copy link
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
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
Copy link

codecov bot commented Mar 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.23%. Comparing base (9df0ff7) to head (dd7af59).
⚠️ Report is 1207 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
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!

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@inoway46
Copy link
Contributor

inoway46 commented Mar 8, 2026

cc @pmarchini

I opened #62056 to fix #60020, but I did not realize this PR was already addressing the same underlying problem, so I closed mine.

I added a regression test in #62056 based on the cluster worker reproduction from #60020, so if it's helpful, please feel free to reuse it.

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.

5 participants