Skip to content

Commit abdb08a

Browse files
chore: detect vitest for test aliases
Co-authored-by: me <me@kentcdodds.com>
1 parent f37910d commit abdb08a

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

vite.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { iconsSpritesheet } from 'vite-plugin-icons-spritesheet'
1212

1313
export default defineConfig((config) => {
1414
const mode = config.mode ?? process.env.NODE_ENV
15+
const isTest = mode === 'test' || Boolean(process.env.VITEST)
1516
return {
1617
build: {
1718
target: 'es2022',
@@ -40,7 +41,7 @@ export default defineConfig((config) => {
4041
},
4142
resolve: {
4243
alias:
43-
mode === 'test'
44+
isTest
4445
? {
4546
'#app/utils/cache.server.ts': path.resolve(
4647
'tests/mocks/cache-server.ts',
@@ -63,7 +64,7 @@ export default defineConfig((config) => {
6364
}),
6465
// it would be really nice to have this enabled in tests, but we'll have to
6566
// wait until https://github.com/remix-run/remix/issues/9871 is fixed
66-
mode === 'test' ? null : reactRouter(),
67+
isTest ? null : reactRouter(),
6768
mode === 'production' && process.env.SENTRY_AUTH_TOKEN
6869
? sentryReactRouter(sentryConfig, config)
6970
: null,

0 commit comments

Comments
 (0)