Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/api/mock.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { vi } from 'vitest'

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.


const market = {
getApples: () => 100
Expand Down