-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
tsconfigPaths
in vitest.config.mts
- Loading branch information
1 parent
e9f3e7a
commit 6a5a375
Showing
1 changed file
with
3 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] } }, | ||
}, | ||
}) |