Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7332 +/- ##
========================================
Coverage 95.04% 95.04%
========================================
Files 619 618 -1
Lines 52012 51799 -213
Branches 9450 9411 -39
========================================
- Hits 49433 49231 -202
+ Misses 2031 2023 -8
+ Partials 548 545 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Description
Implements
expect(fn).toThrowErrorMatchingSnapshot(hint?), one of the two APIs thatexpect/mod.tsstill lists as unavailable (tracking issue #3964 asks for one PR per API, so the inline variant is left for a follow-up).Behaviour follows Jest:
messageof the thrown error is compared with the stored snapshot (-- --updatewrites it, exactly liketoMatchSnapshot());.rejects, the rejection reason's message is used;Received function did not throw;.notis rejected with the same error as the other snapshot matchers;toMatchSnapshot(), so both can be mixed in one test.To avoid duplicating the snapshot bookkeeping, the body of
toMatchSnapshot()(test path/name lookup, key/counter, assert vs. update mode) moved into a privatematchSnapshot()helper that both matchers call.toMatchSnapshot()behaves as before, including the order of its checks; only the matcher name in the "Unable to determine test file path/name" errors is now parameterised. The new matcher is marked@experimentalliketoMatchSnapshot(), andmod.tsnow lists it as supported.Motivation / disclosure: I had some spare AI-assistant quota (Claude Code) and am using it to try to
help projects with open good-first-issues. The change was prepared with Claude Code and verified as listed
below. If it doesn't fit, isn't up to your bar, or you'd simply rather not take it — please feel free to
close it, no hard feelings at all 🙂
Related issue
Part of #3964
Checklist
deno test -A --doc --parallel --trace-leaks expect/→ 237 passed, 0 failed; the newexpect/_to_throw_error_matching_snapshot_test.tshas 9 tests that all fail onmainand pass with this change;deno lint,deno fmt --check,deno task lint:docs,lint:mod-exports,lint:export-names,lint:unstable-deps,lint:circularandtest:browserall pass)CHANGELOG.mdis updated (if applicable) — n/a, release notes are generated from the PR titleExpected.toThrowErrorMatchingSnapshotand the supported/unsupported list inexpect/mod.ts