Skip to content

Commit

Permalink
Use tsconfigPaths in vitest.config.mts
Browse files Browse the repository at this point in the history
  • Loading branch information
aryaemami59 committed Feb 9, 2024
1 parent e9f3e7a commit 6a5a375
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions packages/toolkit/vitest.config.mts
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
import { defineConfig } from 'vitest/config'

import path from 'node:path'
import { fileURLToPath } from 'node:url'
import tsconfigPaths from 'vite-tsconfig-paths'
import { defineConfig } from 'vitest/config'

// No __dirname under Node ESM
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

export default defineConfig({
plugins: [tsconfigPaths({ root: import.meta.dirname })],
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./vitest.setup.ts'],
include: ['./src/**/*.(spec|test).[jt]s?(x)'],
alias: {
// prettier-ignore
'@reduxjs/toolkit/query/react': path.join(__dirname,'./src/query/react/index.ts'), // @remap-prod-remove-line
'@reduxjs/toolkit/query': path.join(__dirname, './src/query/index.ts'), // @remap-prod-remove-line
'@reduxjs/toolkit/react': path.join(__dirname, './src/index.ts'), // @remap-prod-remove-line
'@reduxjs/toolkit': path.join(__dirname, './src/index.ts'), // @remap-prod-remove-line

// this mapping is disabled as we want `dist` imports in the tests only to be used for "type-only" imports which don't play a role for jest
//'^@reduxjs/toolkit/dist/(.*)$': '<rootDir>/src/*',
'@internal': path.join(__dirname, './src'),
},
server: { deps: { inline: ['redux', '@reduxjs/toolkit'] } },
},
})

0 comments on commit 6a5a375

Please sign in to comment.