-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
docs: Fix mock call assertion in documentation #8836
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
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
| const fn = vi.fn() | ||
| fn('hello world') | ||
| fn.mock.calls[0] === ['hello world'] | ||
| fn.mock.calls[0][0] === 'hello world' |
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.
It's important to show the array. If this is a confusing representation, I propose
| fn.mock.calls[0][0] === 'hello world' | |
| fn.mock.calls[0] // == ['hello world'] |
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.
@sheremet-va Yeah this is done throughout the documentation (as I have seen after creating the PR), especially on the Mocks page.
I think it is better to use your proposed style with a comment to not advertise to use this in real tests. I will extend the PR to cover all other places when I am back from vacation :)
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.
@sheremet-va I think the best way would be to change these examples to use real expect assertions:
epect(fn.mock.calls[0]).toEqual(['hello world'])as done in most other examples in the documentation. If you agree, I would adapt similar examples in the docs as well.
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.
we don't want to introduce different concepts in this part of the guide, like assertions
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.
Ok, then I would say it's best to leave it as it is.
Description
Do not compare array literals
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.