Dane Smith
Dane Smith

Reputation: 181

How to have custom expect messages with Vitest?

I'm migrating from Jest to Vitest. I've been using jest-expect-message to help give better messages to students when tests fail.

It isn't written for Vitest, so I don't expect it to work. Is there a Vitest way to achieve the same end?

I've searched the Vitest docs but there isn't anything that jumps out at me.

Upvotes: 6

Views: 2131

Answers (1)

Dane Smith
Dane Smith

Reputation: 181

I think I figured it out -- the Vitest docs do not mention it anywhere, but it's built into the vitest expect by default. Remove the jest-expect-message library if using.

Then it can be the second argument in expect

    expect(list.length, 'Make sure you have a default passenger!').toBe(1);

Upvotes: 10

Related Questions