You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Sport.spec.tsimportSportfrom'../Sport';jest.mock('../Sport');beforeEach(()=>{// This gives me an errorSport.mockClear();});
So, Sport.mockClear() gives me an error, Property 'mockClear' does not exist on type 'typeof Sport'.ts. And Sport doesn't even have mock property.
So I found this issue ts-jest issue, and here's my new code.
// Sport.spec.tsimportSportfrom'../Sport';import{mocked}from'ts-jest/utils';jest.mock('../Sport');beforeEach(()=>{// This worksmocked(Sport).mockClear();});it('Constructor is called',()=>{newSport();expect(Sport).toHaveBeenCalledTimes(1);});it('Mock is clear',()=>{// Succeessexpect(Sport).not.toHaveBeenCalled();});
Question
So, I wonder whySport.mockClear is error and is it the only way to use ts-jest/utils?
The text was updated successfully, but these errors were encountered:
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
馃挰 Questions and Help
Hi, I'm new to
Jest
. I was following the code from es6-class-mocks.And there's something that doesn't work in my code.
I'm using jest with
TypeScript
. And these below are the related codes about my question.So,
Sport.mockClear()
gives me an error,Property 'mockClear' does not exist on type 'typeof Sport'.ts
. AndSport
doesn't even have mock property.So I found this issue ts-jest issue, and here's my new code.
Question
So, I wonder
why
Sport.mockClear is error and is it the only way to usets-jest/utils
?The text was updated successfully, but these errors were encountered: