[Feature]: Transform `jest.mock` of paths using `moduleNameMapper`
enhancement
### Self-service
- [ ] I'd be willing to implement this feature
### Template name
jest
### Input code
```ts
jest.mock('src/example', () => {
return {
example: jest.fn().mockImplementation(() => {
return {};
}),
};
});
```
### Expected Output
```ts
import { vi } from 'vitest';
vi.mock('src/example', () => {
return {
example: vi.fn().mockImplementation(() => {
return {};
}),
};
});
```
### Additional context
https://jestjs.io/docs/configuration#modulenamemapper-objectstring-string--arraystring
Here's an example that allows importing from `src`:
```ts
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'`.
I believe that might be coming from:
https://github.com/trivikr/vitest-codemod/blob/fd7f89d395c61900d5df240b0383209cdf47bff7/packages/jest/src/apis/updateDefaultExportMocks.ts#L31
0 条评论