Skip to content

fix(expect): remove JestExtendError.context from verbose error reporting#9983

Merged
sheremet-va merged 2 commits intovitest-dev:mainfrom
hi-ogawa:fix-remove-jestextenderror-context-from-verbose-errors
Mar 27, 2026
Merged

fix(expect): remove JestExtendError.context from verbose error reporting#9983
sheremet-va merged 2 commits intovitest-dev:mainfrom
hi-ogawa:fix-remove-jestextenderror-context-from-verbose-errors

Conversation

@hi-ogawa
Copy link
Copy Markdown
Collaborator

@hi-ogawa hi-ogawa commented Mar 27, 2026

Description

I just noticed JestExtendError.context now shows up on verbose reporter as a big Serialized Error section. For now, this should be treated as internal and get excluded as yet another skipErrorProperties.

Reproduction: https://stackblitz.com/edit/vitest-dev-vitest-ffwl7esz?file=test%2Frepro.test.ts

expect.extend({
  toAlwaysFail() {
    return { pass: false, message: () => 'always fails' };
  },
});

test('demo', () => {
  expect(1).toAlwaysFail();
});
 FAIL  test/repro.test.ts > demo
Error: always fails
 ❯ test/repro.test.ts:10:13
      8|
      9| test('demo', () => {
     10|   expect(1).toAlwaysFail();
       |             ^
     11| });
     12|
 ❯ new Promise ../../../blitz.4c73681d.js:31:30606

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: { context: { assertionName: 'toAlwaysFail', meta: undefined } }
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

@hi-ogawa hi-ogawa requested a review from macarie March 27, 2026 00:46
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 27, 2026

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 0a99d3d
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/69c5d34021212a0008c060ce
😎 Deploy Preview https://deploy-preview-9983--vitest-dev.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 your Netlify project configuration.

@hi-ogawa hi-ogawa marked this pull request as ready for review March 27, 2026 00:59
Copy link
Copy Markdown
Member

@macarie macarie left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍🏼

@hi-ogawa hi-ogawa changed the title fix: remove JestExtendError.context from verbose errors fix: remove JestExtendError.context from verbose error reporting Mar 27, 2026
@hi-ogawa hi-ogawa changed the title fix: remove JestExtendError.context from verbose error reporting fix(expect): remove JestExtendError.context from verbose error reporting Mar 27, 2026
@sheremet-va sheremet-va merged commit 66751c9 into vitest-dev:main Mar 27, 2026
14 of 16 checks passed
@hi-ogawa hi-ogawa deleted the fix-remove-jestextenderror-context-from-verbose-errors branch March 27, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants