Created
June 18, 2021 14:25
-
-
Save GiuseppeMP/f7015836ceadfd5679e0dc1628480bf8 to your computer and use it in GitHub Desktop.
Como mockar usando jest e type auxiliar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type MockType<T> = { | |
[P in keyof T]?: jest.Mock<unknown>; | |
}; | |
const mockKnexConnection : () => MockType<Knex<any, unknown>> | |
= jest.fn(() => ({ | |
destroy: jest.fn(() => { console.log }), | |
raw: jest.fn((query) => { | |
return new Promise<any>( (res) => { | |
res(query) | |
}) | |
}) | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment