Skip to content
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

Failure to detect prefer-called-with for toHaveBeenCalledOnce #173

Closed
BenGane opened this issue May 11, 2023 · 3 comments · Fixed by #184 or #231
Closed

Failure to detect prefer-called-with for toHaveBeenCalledOnce #173

BenGane opened this issue May 11, 2023 · 3 comments · Fixed by #184 or #231

Comments

@BenGane
Copy link

BenGane commented May 11, 2023

it("some test", () => {
  // I expect the suggestion (prefer toHaveBeenCalledOnceWith)
  expect(mockApi).toHaveBeenCalledOnce(); 
});
veritem pushed a commit that referenced this issue May 21, 2023
veritem added a commit that referenced this issue May 21, 2023
* fix: support toHaveBeenCalledOnce

close #173

* feat: added tests

---------

Co-authored-by: ʀᴀʏ <i@mk1.io>
@molily
Copy link
Contributor

molily commented Aug 18, 2023

Wait, there is no toHaveBeenCalledOnceWith in Vitest. The auto-fix produces an error.

import { expect, it, vi } from 'vitest';

it('works', () => {
  const spy = vi.fn();
  spy();
  expect(spy).toHaveBeenCalledOnceWith();
});
FAIL  test.test.js > works
Error: Invalid Chai property: toHaveBeenCalledOnceWith
 ❯ test.test.js:12:14
     10|   const spy = vi.fn();
     11|   spy();
     12|   expect(spy).toHaveBeenCalledOnceWith();
       |              ^
     13| });

Or am I mistaken?

@veritem veritem reopened this Aug 18, 2023
@veritem
Copy link
Owner

veritem commented Aug 18, 2023

I'll look into it.

@veritem
Copy link
Owner

veritem commented Aug 21, 2023

I can't find toHaveBeenCalledOnceWith in vitest course code. I'm removing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants