Skip to content

Commit

Permalink
Add jest-extended back
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddyGuthridge committed Aug 2, 2024
1 parent 5260017 commit 109bc48
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 14 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cSpell.words": [
"Asciinema",
"firstrun",
"superstruct"
]
}
36 changes: 24 additions & 12 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"cross-fetch": "^4.0.0",
"eslint": "^8.56.0",
"eslint-plugin-svelte": "^2.35.1",
"jest-extended": "^4.0.2",
"simple-git": "^3.25.0",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
Expand Down
9 changes: 9 additions & 0 deletions tests/setup/jestExtended.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// https://jest-extended.jestcommunity.dev/docs/getting-started/setup#use-with-vitest
import type CustomMatchers from 'jest-extended';
import 'vitest';

declare module 'vitest' {
interface Assertion<T = any> extends CustomMatchers<T> {}
interface AsymmetricMatchersContaining<T = any> extends CustomMatchers<T> {}
interface ExpectStatic extends CustomMatchers<T> {}
}
4 changes: 4 additions & 0 deletions tests/setup/jestExtended.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// https://jest-extended.jestcommunity.dev/docs/getting-started/setup#use-with-vitest
import { expect } from 'vitest';
import * as matchers from 'jest-extended';
expect.extend(matchers);
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"strict": true,
"moduleResolution": "bundler",
},
"types": ["vitest/globals"]
// Add Jest extended to vitest
"files": ["tests/setup/jestExtended.d.ts"],
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
// except $lib which is handled by https://kit.svelte.dev/docs/configuration#files
//
Expand Down
6 changes: 5 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ export default mergeConfig(defaultConfig, defineConfig({
// globals: true,
setupFiles: [
'tests/setup/serverBeforeEach.ts',
'tests/setup/jestExtended.ts',
],
fileParallelism: false,
globalSetup: ['tests/setup/globalSetup.ts']
globalSetup: ['tests/setup/globalSetup.ts'],
sequence: {
concurrent: false,
}
},
}));

0 comments on commit 109bc48

Please sign in to comment.