fix(expect): soft assertions continue after .resolves/.rejects promise errors#9843
Merged
hi-ogawa merged 3 commits intovitest-dev:mainfrom Mar 16, 2026
Merged
Conversation
…s proxies When expect.soft() is used with .resolves, a rejection in the awaited promise was not handled softly. Instead of recording the failure and continuing (as expect.soft() should), the rejection propagated to the test, aborting execution of subsequent assertions. Root cause: the .resolves and .rejects proxy callbacks call recordAsyncExpect() without passing the isSoft flag. When isSoft is false/undefined, recordAsyncExpect does not attach a rejection handler to swallow the error and record it in test.result.errors; the returned promise still rejects, so awaiting it terminates the test. Fix: pass utils.flag(this, 'soft') as the isSoft argument to both recordAsyncExpect calls (in the resolves proxy and in the rejects proxy). The same fix also corrects the symmetric case for .rejects: if expect.soft(resolvedPromise).rejects is used, the 'resolved instead of rejecting' error is now recorded softly and execution continues. Fixes vitest-dev#9838
Collaborator
|
CI failing. fix please. |
Co-Authored-By: Claude Opus 4.6 <[email protected]>
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Collaborator
|
Looks good. Can you also add another already working case as test cases? #9838 |
hi-ogawa
approved these changes
Mar 16, 2026
Collaborator
hi-ogawa
left a comment
There was a problem hiding this comment.
It turned out what I requested is already covered in
vitest/test/cli/fixtures/expect-soft/expects/soft.test.ts
Lines 43 to 58 in 8fc9cff
736-c41-2c1-e464fc974
pushed a commit
to Swiss-Armed-Forces/Loom
that referenced
this pull request
Mar 30, 2026
This MR contains the following updates: | Package | Type | Update | Change | OpenSSF | |---|---|---|---|---| | [@typescript-eslint/eslint-plugin](https://typescript-eslint.io/packages/eslint-plugin) ([source](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin)) | devDependencies | patch | [`8.57.0` → `8.57.2`](https://renovatebot.com/diffs/npm/@typescript-eslint%2feslint-plugin/8.57.0/8.57.2) | [](https://securityscorecards.dev/viewer/?uri=github.com/typescript-eslint/typescript-eslint) | | [@typescript-eslint/parser](https://typescript-eslint.io/packages/parser) ([source](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser)) | devDependencies | patch | [`8.57.0` → `8.57.2`](https://renovatebot.com/diffs/npm/@typescript-eslint%2fparser/8.57.0/8.57.2) | [](https://securityscorecards.dev/viewer/?uri=github.com/typescript-eslint/typescript-eslint) | | [i18next](https://www.i18next.com) ([source](https://github.com/i18next/i18next)) | dependencies | patch | [`25.10.9` → `25.10.10`](https://renovatebot.com/diffs/npm/i18next/25.10.9/25.10.10) | [](https://securityscorecards.dev/viewer/?uri=github.com/i18next/i18next) | | [react-router-dom](https://github.com/remix-run/react-router) ([source](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom)) | dependencies | patch | [`7.13.1` → `7.13.2`](https://renovatebot.com/diffs/npm/react-router-dom/7.13.1/7.13.2) | [](https://securityscorecards.dev/viewer/?uri=github.com/remix-run/react-router) | | [typescript-eslint](https://typescript-eslint.io/packages/typescript-eslint) ([source](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/typescript-eslint)) | devDependencies | patch | [`8.57.0` → `8.57.2`](https://renovatebot.com/diffs/npm/typescript-eslint/8.57.0/8.57.2) | [](https://securityscorecards.dev/viewer/?uri=github.com/typescript-eslint/typescript-eslint) | | [vitest](https://vitest.dev) ([source](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest)) | devDependencies | patch | [`4.1.0` → `4.1.2`](https://renovatebot.com/diffs/npm/vitest/4.1.0/4.1.2) | [](https://securityscorecards.dev/viewer/?uri=github.com/vitest-dev/vitest) | --- ### Release Notes <details> <summary>typescript-eslint/typescript-eslint (@​typescript-eslint/eslint-plugin)</summary> ### [`v8.57.2`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8572-2026-03-23) [Compare Source](typescript-eslint/typescript-eslint@v8.57.1...v8.57.2) ##### 🩹 Fixes - **eslint-plugin:** \[prefer-readonly-parameter-types] preserve type alias infomation ([#​11954](typescript-eslint/typescript-eslint#11954)) - **eslint-plugin:** \[no-useless-default-assignment] skip reporting false positives for unresolved type parameters ([#​12127](typescript-eslint/typescript-eslint#12127)) - **eslint-plugin:** \[no-unsafe-return] false positive on unwrapping generic ([#​12125](typescript-eslint/typescript-eslint#12125)) - **eslint-plugin:** \[no-restricted-types] flag banned generics in extends or implements ([#​12120](typescript-eslint/typescript-eslint#12120)) - **eslint-plugin:** \[array-type] ignore Array and ReadonlyArray without type arguments ([#​11971](typescript-eslint/typescript-eslint#11971)) - **eslint-plugin:** \[prefer-optional-chain] remove dangling closing parenthesis ([#​11865](typescript-eslint/typescript-eslint#11865)) ##### ❤️ Thank You - Kirk Waiblinger [@​kirkwaiblinger](https://github.com/kirkwaiblinger) - Konv Suu - mdm317 - Newton Yuan [@​NewtonYuan](https://github.com/NewtonYuan) - SungHyun627 [@​SungHyun627](https://github.com/SungHyun627) - Tamashoo [@​Tamashoo](https://github.com/Tamashoo) See [GitHub Releases](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v8.57.2) for more information. You can read about our [versioning strategy](https://typescript-eslint.io/users/versioning) and [releases](https://typescript-eslint.io/users/releases) on our website. ### [`v8.57.1`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8571-2026-03-16) [Compare Source](typescript-eslint/typescript-eslint@v8.57.0...v8.57.1) ##### 🩹 Fixes - **eslint-plugin:** \[prefer-optional-chain] no report for property on intersection type ([#​12126](typescript-eslint/typescript-eslint#12126)) ##### ❤️ Thank You - Newton Yuan [@​NewtonYuan](https://github.com/NewtonYuan) See [GitHub Releases](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v8.57.1) for more information. You can read about our [versioning strategy](https://typescript-eslint.io/users/versioning) and [releases](https://typescript-eslint.io/users/releases) on our website. </details> <details> <summary>typescript-eslint/typescript-eslint (@​typescript-eslint/parser)</summary> ### [`v8.57.2`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/parser/CHANGELOG.md#8572-2026-03-23) [Compare Source](typescript-eslint/typescript-eslint@v8.57.1...v8.57.2) This was a version bump only for parser to align it with other projects, there were no code changes. See [GitHub Releases](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v8.57.2) for more information. You can read about our [versioning strategy](https://typescript-eslint.io/users/versioning) and [releases](https://typescript-eslint.io/users/releases) on our website. ### [`v8.57.1`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/parser/CHANGELOG.md#8571-2026-03-16) [Compare Source](typescript-eslint/typescript-eslint@v8.57.0...v8.57.1) This was a version bump only for parser to align it with other projects, there were no code changes. See [GitHub Releases](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v8.57.1) for more information. You can read about our [versioning strategy](https://typescript-eslint.io/users/versioning) and [releases](https://typescript-eslint.io/users/releases) on our website. </details> <details> <summary>i18next/i18next (i18next)</summary> ### [`v25.10.10`](https://github.com/i18next/i18next/blob/HEAD/CHANGELOG.md#251010) [Compare Source](i18next/i18next@v25.10.9...v25.10.10) - feat: suppress support notice automatically in production environments (`NODE_ENV=production`) </details> <details> <summary>remix-run/react-router (react-router-dom)</summary> ### [`v7.13.2`](https://github.com/remix-run/react-router/blob/HEAD/packages/react-router-dom/CHANGELOG.md#7132) [Compare Source](https://github.com/remix-run/react-router/compare/[email protected]@7.13.2) ##### Patch Changes - Updated dependencies: - `[email protected]` </details> <details> <summary>typescript-eslint/typescript-eslint (typescript-eslint)</summary> ### [`v8.57.2`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/typescript-eslint/CHANGELOG.md#8572-2026-03-23) [Compare Source](typescript-eslint/typescript-eslint@v8.57.1...v8.57.2) This was a version bump only for typescript-eslint to align it with other projects, there were no code changes. See [GitHub Releases](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v8.57.2) for more information. You can read about our [versioning strategy](https://typescript-eslint.io/users/versioning) and [releases](https://typescript-eslint.io/users/releases) on our website. ### [`v8.57.1`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/typescript-eslint/CHANGELOG.md#8571-2026-03-16) [Compare Source](typescript-eslint/typescript-eslint@v8.57.0...v8.57.1) This was a version bump only for typescript-eslint to align it with other projects, there were no code changes. See [GitHub Releases](https://github.com/typescript-eslint/typescript-eslint/releases/tag/v8.57.1) for more information. You can read about our [versioning strategy](https://typescript-eslint.io/users/versioning) and [releases](https://typescript-eslint.io/users/releases) on our website. </details> <details> <summary>vitest-dev/vitest (vitest)</summary> ### [`v4.1.2`](https://github.com/vitest-dev/vitest/releases/tag/v4.1.2) [Compare Source](vitest-dev/vitest@v4.1.1...v4.1.2) This release bumps Vitest's `flatted` version and removes version pinning to resolve `flatted`'s CVE related issues ([#​9975](vitest-dev/vitest#9975)). ##### 🐞 Bug Fixes - Don't resolve `setupFiles` from parent directory - by [@​hi-ogawa](https://github.com/hi-ogawa) in [#​9960](vitest-dev/vitest#9960) [<samp>(7aa93)</samp>](vitest-dev/vitest@7aa937776) - Ensure sequential mock/unmock resolution - by [@​hi-ogawa](https://github.com/hi-ogawa) and **Claude Opus 4.6** in [#​9830](vitest-dev/vitest#9830) [<samp>(7c065)</samp>](vitest-dev/vitest@7c06598db) - **browser**: Take failure screenshot if `toMatchScreenshot` can't capture a stable screenshot - by [@​macarie](https://github.com/macarie) in [#​9847](vitest-dev/vitest#9847) [<samp>(faace)</samp>](vitest-dev/vitest@faace1fbe) - **coverage**: Correct `coverageConfigDefaults` values and types - by [@​Arthie](https://github.com/Arthie) in [#​9940](vitest-dev/vitest#9940) [<samp>(b3c99)</samp>](vitest-dev/vitest@b3c992cb2) - **pretty-format**: Fix output limit over counting - by [@​hi-ogawa](https://github.com/hi-ogawa) in [#​9965](vitest-dev/vitest#9965) [<samp>(d3b7a)</samp>](vitest-dev/vitest@d3b7a40fa) - Disable colors if agent is detected - by [@​sheremet-va](https://github.com/sheremet-va) and [@​AriPerkkio](https://github.com/AriPerkkio) in [#​9851](vitest-dev/vitest#9851) [<samp>(6f97b)</samp>](vitest-dev/vitest@6f97b55dd) ##### [View changes on GitHub](vitest-dev/vitest@v4.1.1...v4.1.2) ### [`v4.1.1`](https://github.com/vitest-dev/vitest/releases/tag/v4.1.1) [Compare Source](vitest-dev/vitest@v4.1.0...v4.1.1) ##### 🚀 Features - **experimental**: - Expose `matchesTags` to test if the current filter matches tags - by [@​sheremet-va](https://github.com/sheremet-va) in [#​9913](vitest-dev/vitest#9913) [<samp>(eec53)</samp>](vitest-dev/vitest@eec53d9f5) - Introduce `experimental.vcsProvider` - by [@​sheremet-va](https://github.com/sheremet-va) in [#​9928](vitest-dev/vitest#9928) [<samp>(56115)</samp>](vitest-dev/vitest@561150036) ##### 🐞 Bug Fixes - Mark `TestProject.testFilesList` internal properly - by [@​sapphi-red](https://github.com/sapphi-red) in [#​9867](vitest-dev/vitest#9867) [<samp>(54f26)</samp>](vitest-dev/vitest@54f2660f5) - Detect fixture that returns without calling `use` - by [@​oilater](https://github.com/oilater) in [#​9831](vitest-dev/vitest#9831) and [#​9861](vitest-dev/vitest#9861) [<samp>(633ae)</samp>](vitest-dev/vitest@633ae2303) - Drop vite 8.beta support - by [@​AriPerkkio](https://github.com/AriPerkkio) in [#​9862](vitest-dev/vitest#9862) [<samp>(b78f5)</samp>](vitest-dev/vitest@b78f5389d) - Type regression in vi.mocked() static class methods - by [@​purepear](https://github.com/purepear) and [@​hi-ogawa](https://github.com/hi-ogawa) in [#​9857](vitest-dev/vitest#9857) [<samp>(90926)</samp>](vitest-dev/vitest@90926641b) - Properly re-evaluate actual modules of mocked external - by [@​hi-ogawa](https://github.com/hi-ogawa) in [#​9898](vitest-dev/vitest#9898) [<samp>(ae5ec)</samp>](vitest-dev/vitest@ae5ec03ef) - Preserve coverage report when html reporter overlaps - by [@​hi-ogawa](https://github.com/hi-ogawa) in [#​9889](vitest-dev/vitest#9889) [<samp>(2d81a)</samp>](vitest-dev/vitest@2d81ad897) - Provide `vi.advanceTimers` to the preview provider - by [@​sheremet-va](https://github.com/sheremet-va) in [#​9891](vitest-dev/vitest#9891) [<samp>(1bc3e)</samp>](vitest-dev/vitest@1bc3e63be) - Don't leak event listener in playwright provider - by [@​sheremet-va](https://github.com/sheremet-va) in [#​9910](vitest-dev/vitest#9910) [<samp>(d9355)</samp>](vitest-dev/vitest@d93550ff7) - Open browser in `--standalone` mode without running tests - by [@​sheremet-va](https://github.com/sheremet-va) in [#​9911](vitest-dev/vitest#9911) [<samp>(e78ad)</samp>](vitest-dev/vitest@e78adcf97) - Guard disposable and optional `body` - by [@​sheremet-va](https://github.com/sheremet-va) in [#​9912](vitest-dev/vitest#9912) [<samp>(6fdb2)</samp>](vitest-dev/vitest@6fdb2ba61) - Resolve `retry.condition` RegExp serialization issue - by [@​nstepien](https://github.com/nstepien) and [@​hi-ogawa](https://github.com/hi-ogawa) in [#​9942](vitest-dev/vitest#9942) [<samp>(7b605)</samp>](vitest-dev/vitest@7b6054328) - **collect**: - Don't treat extra props on `test` return as tests - by [@​sheremet-va](https://github.com/sheremet-va) in [#​9871](vitest-dev/vitest#9871) [<samp>(141e7)</samp>](vitest-dev/vitest@141e72aa1) - **coverage**: - Simplify provider types - by [@​AriPerkkio](https://github.com/AriPerkkio) in [#​9931](vitest-dev/vitest#9931) [<samp>(aaf9f)</samp>](vitest-dev/vitest@aaf9f18ae) - Load built-in provider without module runner - by [@​AriPerkkio](https://github.com/AriPerkkio) in [#​9939](vitest-dev/vitest#9939) [<samp>(bf892)</samp>](vitest-dev/vitest@bf8920817) - **expect**: - Soft assertions continue after .resolves/.rejects promise errors - by [@​mixelburg](https://github.com/mixelburg), **Maks Pikov**, **Claude Opus 4.6 (1M context)** and [@​hi-ogawa](https://github.com/hi-ogawa) in [#​9843](vitest-dev/vitest#9843) [<samp>(6d74b)</samp>](vitest-dev/vitest@6d74b4948) - Fix sinon-chai style API - by [@​hi-ogawa](https://github.com/hi-ogawa) in [#​9943](vitest-dev/vitest#9943) [<samp>(0f08d)</samp>](vitest-dev/vitest@0f08dda2c) - **pretty-format**: - Limit output for large object - by [@​hi-ogawa](https://github.com/hi-ogawa) and **Claude Opus 4.6 (1M context)** in [#​9949](vitest-dev/vitest#9949) [<samp>(0d5f9)</samp>](vitest-dev/vitest@0d5f9d6ef) ##### [View changes on GitHub](vitest-dev/vitest@v4.1.0...v4.1.1) </details> --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My44NC4yIiwidXBkYXRlZEluVmVyIjoiNDMuOTEuNSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiZGVwZW5kZW5jaWVzIiwicmVub3ZhdGUiXX0=--> See merge request swiss-armed-forces/cyber-command/cea/loom!411 Co-authored-by: persistent-chamoisee yield <persistent-chamoisee-yield-9fd-f86-2e0-f31d23b2e@swiss-armed-forces-open-source.ch>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
When
expect.soft()is combined with.resolvesand the awaited promise rejects, the test aborts instead of recording the failure and continuing (which is whatexpect.softis designed to do).The symmetric case also fails:
expect.soft(resolvedPromise).rejectsaborts when the promise resolves.Fixes #9838
Root cause
Inside both the
.resolvesand.rejectsproxy accessors, the method interceptor creates a new promise (thePromise.resolve(obj).then(...).catch(...)chain), then hands it torecordAsyncExpect:recordAsyncExpecthas a specialisSoftbranch:Without
isSoft, the rejection propagates through the returned promise wrapper; when the callerawaits it, the test runner sees an unhandled rejection and aborts the test.Fix
Pass
utils.flag(this, 'soft')(which is already set byexpect.soft()) as the fifth argument in bothrecordAsyncExpectcalls.Tests added
Added two new fixture test cases to
test/cli/fixtures/expect-soft/expects/soft.test.ts:promise rejection— two consecutiveexpect.soft(rejectedPromise).resolves.toBe(...)assertions; both should execute and both failures should be reported (regression for issue)promise resolved instead of rejecting— two consecutiveexpect.soft(resolvedPromise).rejects.toBe(...)assertions; same expectation for symmetric caseAnd corresponding expectations in
test/cli/test/expect-soft.test.tsthat verify both failure messages appear in stderr.