Skip to content

Conversation

@danielrentz
Copy link
Contributor

Description

Do not compare array literals

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:.

@netlify
Copy link

netlify bot commented Oct 27, 2025

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit bac371e
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/6909de8ce4a3fa0008c5fe8c
😎 Deploy Preview https://deploy-preview-8836--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.

const fn = vi.fn()
fn('hello world')
fn.mock.calls[0] === ['hello world']
fn.mock.calls[0][0] === 'hello world'
Copy link
Member

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

Suggested change
fn.mock.calls[0][0] === 'hello world'
fn.mock.calls[0] // == ['hello world']

Copy link
Contributor Author

@danielrentz danielrentz Oct 28, 2025

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 :)

Copy link
Contributor Author

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.

Copy link
Member

@sheremet-va sheremet-va Nov 4, 2025

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

Copy link
Contributor Author

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.

@danielrentz danielrentz closed this Nov 4, 2025
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.

2 participants