-
Notifications
You must be signed in to change notification settings - Fork 662
feat: add createAssertSnapshot #2403
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add createAssertSnapshot #2403
Conversation
kt3k
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bcheidemann Thanks for the PR. The API design and testing look good to me. Nice work!
Can you also add docs in testing/README.md?
bartlomieju
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good!
testing/asserts.ts
Outdated
|
|
||
| /** Executes a function which returns a promise, expecting it to reject. */ | ||
| export function assertRejects( | ||
| export function assertRejects<T = unknown>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like an unrelated change, what's the reason for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, probably it's better to keep this unknown as the thrown value is not type checked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for flagging, I will remove this change and refactor the test to use the format outlined below
testing/snapshot_test.ts
Outdated
| name: "[MISSING SNAPSHOT]", | ||
| }); | ||
|
|
||
| const err = await assertRejects<AssertionError>(async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use assertRejects(fn, AssertionError) call, that will give correct type to err
Yeah no problem :) |
kt3k
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
| snapshot files. As such, the allow list for `--allow-read` and `--allow-write` | ||
| can be limited to only include existing snapshot files, if so desired. | ||
|
|
||
| ### Options: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice docs!
Closes #2214