Skip to content

Commit dafc68e

Browse files
committed
hack to get $app/stores import working
1 parent 2494c5b commit dafc68e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

packages/sveltekit/.empty.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Hack to get $app/stores import working (can't mock it in tests if path is not resolvable).
2+
// See: https://github.com/vitest-dev/vitest/issues/4630

packages/sveltekit/vite.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { dirname, resolve } from 'path';
2+
import { fileURLToPath } from 'url';
3+
14
import type { UserConfig } from 'vitest';
25

36
import baseConfig from '../../vite/vite.config';
@@ -10,5 +13,11 @@ export default {
1013
...(baseConfig as UserConfig & { test: any }).test,
1114
environment: 'jsdom',
1215
setupFiles: ['./test/vitest.setup.ts'],
16+
alias: [
17+
{
18+
find: '$app/stores',
19+
replacement: resolve(fileURLToPath(dirname(import.meta.url)), '/.empty.js'),
20+
},
21+
],
1322
},
1423
};

0 commit comments

Comments
 (0)