Skip to content

Commit

Permalink
fix(vitest): fix issues with imports of react-router-dom outside of s…
Browse files Browse the repository at this point in the history
…cope
  • Loading branch information
seanes committed Mar 5, 2025
1 parent 0ed7832 commit 93485f0
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"tsx": "^4.16.5",
"typescript": "^5.2.2",
"vite": "^5.0.8",
"vitest": "^2.0.0",
"vitest": "^3.0.7",
"web-streams-polyfill": "^3.3.3"
},
"msw": {
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/tests/setup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { vitest } from 'vitest';
import { i18n } from '../src/i18n/config';

i18n.init();
window.scrollTo = vitest.fn();
10 changes: 7 additions & 3 deletions packages/frontend/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import { defineConfig } from 'vitest/config';

export default defineConfig({
plugins: [react()],
define: process.env.VITEST ? {} : { global: 'window' },
test: {
server: {
deps: {
inline: ['react-router'],
deps: {
optimizer: {
web: {
include: ['react-router-dom'],
enabled: true,
},
},
},
exclude: ['node_modules', 'tests'], // tests for Playwright
Expand Down
190 changes: 188 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 93485f0

Please sign in to comment.