Alias config
amritk opened this issue · 1 comments
amritk commented
Just trying to get aliases working and I can't seem to figure it out. I have tried any combination of jest.config.js as well as vite.config.js, you can see my commit here
jest.config.js
export default {
preset: 'vite-jest',
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1'
},
setupFilesAfterEnv: ['<rootDir>/src/setupTests.js'],
testMatch: [
'<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}',
'<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}',
],
testEnvironment: 'jest-environment-jsdom'
}
vite.config.js
import path from 'path'
import { defineConfig } from 'vite'
import reactRefresh from '@vitejs/plugin-react-refresh'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [...(process.env.NODE_ENV !== 'test' ? [reactRefresh()] : [])],
resolve: {
alias: {
'@': path.join(path.resolve('./src'))
}
}
})
Is it currently possible in vite-jest?
haoqunjiang commented
Supported in 0.1.0. It will follow Vite's alias config.