Open billdybas opened 1 year ago
jest
jest.mock('src/example', () => { return { example: jest.fn().mockImplementation(() => { return {}; }), }; });
import { vi } from 'vitest'; vi.mock('src/example', () => { return { example: vi.fn().mockImplementation(() => { return {}; }), }; });
https://jestjs.io/docs/configuration#modulenamemapper-objectstring-string--arraystring
Here's an example that allows importing from src:
src
moduleNameMapper: { '^src/(.*)$': '<rootDir>/src/$1', },
Currently files with mocks like this are skipped w/ a jscodeshift error like Cannot find module 'src/__tests__/src/example'.
Cannot find module 'src/__tests__/src/example'
I believe that might be coming from: https://github.com/trivikr/vitest-codemod/blob/fd7f89d395c61900d5df240b0383209cdf47bff7/packages/jest/src/apis/updateDefaultExportMocks.ts#L31
Self-service
Template name
jest
Input code
Expected Output
Additional context
https://jestjs.io/docs/configuration#modulenamemapper-objectstring-string--arraystring
Here's an example that allows importing from
src
:Currently files with mocks like this are skipped w/ a jscodeshift error like
Cannot find module 'src/__tests__/src/example'
.I believe that might be coming from: https://github.com/trivikr/vitest-codemod/blob/fd7f89d395c61900d5df240b0383209cdf47bff7/packages/jest/src/apis/updateDefaultExportMocks.ts#L31