Skip to content

Commit

Permalink
chore: add alias for vitest package
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Dec 30, 2022
1 parent 90d07e6 commit cf39481
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/vitest/src/integrations/chai/index.ts
Expand Up @@ -18,7 +18,7 @@ export function createExpect(test?: Test) {
}) as Vi.ExpectStatic
Object.assign(expect, chai.expect)

expect.getState = () => getState(expect)
expect.getState = () => getState<MatcherState>(expect)
expect.setState = state => setState(state as Partial<MatcherState>, expect)

setState<MatcherState>({
Expand Down
2 changes: 1 addition & 1 deletion test/core/test/file-path.test.ts
Expand Up @@ -4,7 +4,7 @@ import { isWindows, slash, toFilePath } from '../../../packages/vite-node/src/ut
// @ts-expect-error aliased to ../src/aliased-mod.ts
import { getPaths as getAbsoluteAliasedPaths } from '$/aliased-mod'
// @ts-expect-error aliased to ../src/aliased-mod.ts
import { getPaths as getRelativeAliasedPath } from '@/aliased-mod'
import { getPaths as getRelativeAliasedPath } from '#/aliased-mod'

vi.mock('fs')

Expand Down
2 changes: 1 addition & 1 deletion test/core/test/imports.test.ts
Expand Up @@ -20,7 +20,7 @@ test('Relative imports in imported modules work', async () => {
test('dynamic aliased import works', async () => {
const stringTimeoutMod = await import('./../src/timeout')

const timeoutPath = '@/timeout'
const timeoutPath = '#/timeout'
const variableTimeoutMod = await import(timeoutPath)

expect(stringTimeoutMod).toBe(variableTimeoutMod)
Expand Down
3 changes: 2 additions & 1 deletion test/core/vitest.config.ts
Expand Up @@ -33,8 +33,9 @@ export default defineConfig({
},
resolve: {
alias: [
{ find: '@', replacement: resolve(__dirname, 'src') },
{ find: '#', replacement: resolve(__dirname, 'src') },
{ find: '$', replacement: 'src' },
{ find: '@vitest', replacement: resolve(__dirname, '..', '..', 'packages') },
],
},
test: {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Expand Up @@ -41,6 +41,7 @@
"**/dist/**",
"./packages/vitest/dist/**",
"./packages/vitest/*.d.ts",
"./packages/vitest/*.d.cts",
"./packages/ui/client/**",
"./examples/**/*.*",
"./bench/**",
Expand Down

0 comments on commit cf39481

Please sign in to comment.