Reputation: 440
I'm trying to run some tests in a project that was created using VITE + TS, and I'm getting the following error:
The module typescript-cookie is the only one it's not being found. If remove this module all tests work fine!
My jest.config.ts
module.exports = {
testEnvironment: 'jest-environment-jsdom',
collectCoverageFrom: ['<rootDir>/src/**/*.{ts,tsx}'],
coverageDirectory: 'coverage',
setupFilesAfterEnv: ['<rootDir>/src/config/jest-setup.ts'],
transformIgnorePatterns: ['/node_modules/(?!@element)/'],
transform: {
'^.+\\.[jt]sx?$': 'babel-jest',
},
moduleNameMapper: {
'@hooks': ['<rootDir>/src/commons/hooks'],
'@contexts': ['<rootDir>/src/commons/contexts'],
'@commons': ['<rootDir>/src/commons'],
'@mock': ['<rootDir>/src/commons/mock'],
'@common/components': ['<rootDir>/src/commons/components'],
'@enum': ['<rootDir>/src/commons/enum/'],
'@interfaces': ['<rootDir>/src/commons/interfaces/'],
'@utils': ['<rootDir>/src/commons/utils/'],
'@mainRoutes': ['<rootDir>/src/router'],
'@services': ['<rootDir>/src/commons/services'],
},
};
vite.config.ts
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@hooks': '/src/commons/hooks',
'@enum': '/src/commons/enum',
'@mock': '/src/commons/mock',
'@common/components': '/src/commons/components',
'@services': '/src/commons/services',
'@common': '/src/commons',
'@contexts': '/src/commons/contexts',
'@interfaces': '/src/commons/interfaces',
'@utils': '/src/commons/utils',
'@mainRoutes': '/src/router',
},
},
});
```
Upvotes: 1
Views: 830
Reputation: 379
I've been experiencing the same error in a project that was created with Create React App. Assuming it's an issue with the library, I filed a bug report.
https://github.com/carhartl/typescript-cookie/issues/110
Upvotes: 1