Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: prevent double teardown on test environment error#15731

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
cpojer merged 1 commit intojestjs:mainfromnoomorph:fix/teardown-concealed-error
Jul 9, 2025

Conversation

@noomorph
Copy link
Contributor

Summary

This PR fixes a regression where errors thrown from a custom environment’steardown() method were masked by an internal error, rather than being reported to the user. This led to confusing error messages and made debugging custom environments difficult.

  • Ensures thatisTornDown is always set in afinally block, even ifenvironment.teardown() throws. This prevents double teardown and ensures the real error is surfaced.
  • Adds a real end-to-end (e2e) test that:
    • Uses a custom environment that throws inteardown()
    • Asserts that Jest reports the actual error, not an internal or misleading one
    • Prevents future regressions of this kind

Why

  • The regression was reported in#15730.
  • Without this fix, users see a confusing internal error (The "object" argument must be of type object. Received null) instead of the real cause.
  • The new e2e test ensures this scenario is covered in CI.

Test plan

  • The new e2e test fails on the old behavior and passes with this fix.
  • The test runs a trivial test file using a custom environment that throws inteardown(), and asserts that the error is reported as expected.
  • CI will now catch regressions of this kind.

@netlify
Copy link

netlifybot commentedJul 9, 2025
edited
Loading

Deploy Preview forjestjs ready!

Builtwithout sensitive environment variables

NameLink
🔨 Latest commitcac64d4
🔍 Latest deploy loghttps://app.netlify.com/projects/jestjs/deploys/686e126e938d1e00089a4dbc
😎 Deploy Previewhttps://deploy-preview-15731--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to yourNetlify project configuration.

@noomorphnoomorph mentioned this pull requestJul 9, 2025
@pkg-pr-new
Copy link

pkg-pr-newbot commentedJul 9, 2025
edited
Loading

Open in StackBlitz

babel-jest

npm i https://pkg.pr.new/babel-jest@15731

babel-plugin-jest-hoist

npm i https://pkg.pr.new/babel-plugin-jest-hoist@15731

babel-preset-jest

npm i https://pkg.pr.new/babel-preset-jest@15731

create-jest

npm i https://pkg.pr.new/create-jest@15731

@jest/diff-sequences

npm i https://pkg.pr.new/@jest/diff-sequences@15731

expect

npm i https://pkg.pr.new/expect@15731

@jest/expect-utils

npm i https://pkg.pr.new/@jest/expect-utils@15731

jest

npm i https://pkg.pr.new/jest@15731

jest-changed-files

npm i https://pkg.pr.new/jest-changed-files@15731

jest-circus

npm i https://pkg.pr.new/jest-circus@15731

jest-cli

npm i https://pkg.pr.new/jest-cli@15731

jest-config

npm i https://pkg.pr.new/jest-config@15731

@jest/console

npm i https://pkg.pr.new/@jest/console@15731

@jest/core

npm i https://pkg.pr.new/@jest/core@15731

@jest/create-cache-key-function

npm i https://pkg.pr.new/@jest/create-cache-key-function@15731

jest-diff

npm i https://pkg.pr.new/jest-diff@15731

jest-docblock

npm i https://pkg.pr.new/jest-docblock@15731

jest-each

npm i https://pkg.pr.new/jest-each@15731

@jest/environment

npm i https://pkg.pr.new/@jest/environment@15731

jest-environment-jsdom

npm i https://pkg.pr.new/jest-environment-jsdom@15731

@jest/environment-jsdom-abstract

npm i https://pkg.pr.new/@jest/environment-jsdom-abstract@15731

jest-environment-node

npm i https://pkg.pr.new/jest-environment-node@15731

@jest/expect

npm i https://pkg.pr.new/@jest/expect@15731

@jest/fake-timers

npm i https://pkg.pr.new/@jest/fake-timers@15731

@jest/get-type

npm i https://pkg.pr.new/@jest/get-type@15731

@jest/globals

npm i https://pkg.pr.new/@jest/globals@15731

jest-haste-map

npm i https://pkg.pr.new/jest-haste-map@15731

jest-jasmine2

npm i https://pkg.pr.new/jest-jasmine2@15731

jest-leak-detector

npm i https://pkg.pr.new/jest-leak-detector@15731

jest-matcher-utils

npm i https://pkg.pr.new/jest-matcher-utils@15731

jest-message-util

npm i https://pkg.pr.new/jest-message-util@15731

jest-mock

npm i https://pkg.pr.new/jest-mock@15731

@jest/pattern

npm i https://pkg.pr.new/@jest/pattern@15731

jest-phabricator

npm i https://pkg.pr.new/jest-phabricator@15731

jest-regex-util

npm i https://pkg.pr.new/jest-regex-util@15731

@jest/reporters

npm i https://pkg.pr.new/@jest/reporters@15731

jest-resolve

npm i https://pkg.pr.new/jest-resolve@15731

jest-resolve-dependencies

npm i https://pkg.pr.new/jest-resolve-dependencies@15731

jest-runner

npm i https://pkg.pr.new/jest-runner@15731

jest-runtime

npm i https://pkg.pr.new/jest-runtime@15731

@jest/schemas

npm i https://pkg.pr.new/@jest/schemas@15731

jest-snapshot

npm i https://pkg.pr.new/jest-snapshot@15731

@jest/snapshot-utils

npm i https://pkg.pr.new/@jest/snapshot-utils@15731

@jest/source-map

npm i https://pkg.pr.new/@jest/source-map@15731

@jest/test-result

npm i https://pkg.pr.new/@jest/test-result@15731

@jest/test-sequencer

npm i https://pkg.pr.new/@jest/test-sequencer@15731

@jest/transform

npm i https://pkg.pr.new/@jest/transform@15731

@jest/types

npm i https://pkg.pr.new/@jest/types@15731

jest-util

npm i https://pkg.pr.new/jest-util@15731

jest-validate

npm i https://pkg.pr.new/jest-validate@15731

jest-watcher

npm i https://pkg.pr.new/jest-watcher@15731

jest-worker

npm i https://pkg.pr.new/jest-worker@15731

pretty-format

npm i https://pkg.pr.new/pretty-format@15731

commit:cac64d4

@noomorphnoomorphforce-pushed thefix/teardown-concealed-error branch fromba5b2b1 toec50f9cCompareJuly 9, 2025 06:54
@noomorphnoomorphforce-pushed thefix/teardown-concealed-error branch fromec50f9c tocac64d4CompareJuly 9, 2025 06:55
@noomorph
Copy link
ContributorAuthor

Please note that the test coverage reduction report is erroneous. This case has been covered by E2E test I added.

Copy link
Member

@cpojercpojer left a comment

Choose a reason for hiding this comment

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

Thank you!

@cpojercpojer merged commit37b1686 intojestjs:mainJul 9, 2025
74 of 76 checks passed
@noomorphnoomorph deleted the fix/teardown-concealed-error branchJuly 9, 2025 15:16
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend usingStackOverflow or ourdiscord channel for questions.

@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsAug 9, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@cpojercpojercpojer approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Bug]: Jest 30 environment teardown error handling regression

2 participants

@noomorph@cpojer

[8]ページ先頭

©2009-2025 Movatter.jp