Closed karlbennett closed 4 years ago
Is it possible to mock imports with this library? I can do this with Jest mock as follows: MyModule.ts
MyModule.ts
import { someFunction } from "some-module"; export const myFunction = (): string => someFunction();
MyModule.test.js
import { someFunction } from 'some-module'; import { myFunction } from './MyModule'; jest.mock('some-module'); beforeEach(() => { someFunction.mockClear(); }); test('Can mock an imported function.', () => { const expected = 'some string'; // Given someFunction.mockReturnValueOnce(expected); // When const actual = myFunction(); // Then expect(actual).toBe(expected); });
Not possible. And probably will not be possible as ts-mockito is not a test runner and can't override imports.
ts-mockito
Is it possible to mock imports with this library? I can do this with Jest mock as follows:
MyModule.ts
MyModule.test.js