Skip to content

Commit 16e78ec

Browse files
committed
Move testing to jest
1 parent 103b2dc commit 16e78ec

File tree

6 files changed

+2512
-199
lines changed

6 files changed

+2512
-199
lines changed

.eslintrc.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module.exports = {
2+
root: true,
3+
parserOptions: {
4+
sourceType: 'module',
5+
},
6+
7+
extends: ['@metamask/eslint-config'],
8+
9+
overrides: [
10+
{
11+
files: ['**/*.js'],
12+
extends: ['@metamask/eslint-config-nodejs'],
13+
},
14+
15+
{
16+
files: ['**/*.{ts,tsx}'],
17+
extends: ['@metamask/eslint-config-typescript'],
18+
rules: {
19+
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
20+
},
21+
},
22+
23+
{
24+
files: ['**/*.test.ts', '**/*.test.js'],
25+
extends: ['@metamask/eslint-config-jest'],
26+
rules: {
27+
'@typescript-eslint/no-shadow': [
28+
'error',
29+
{ allow: ['describe', 'expect', 'it'] },
30+
],
31+
},
32+
},
33+
],
34+
35+
ignorePatterns: [
36+
'!.prettierrc.js',
37+
'**/!.eslintrc.js',
38+
'**/dist*/',
39+
'**/*__GENERATED__*',
40+
'**/build',
41+
'**/public',
42+
'**/.cache',
43+
],
44+
};

packages/ui/package.json

+22-4
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,39 @@
88
"preview": "vite preview",
99
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
1010
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
11-
"test:unit": "vitest",
11+
"test:unit": "jest",
1212
"lint": "prettier --plugin-search-dir . --check .",
1313
"format": "prettier --plugin-search-dir . --write ."
1414
},
1515
"devDependencies": {
1616
"@sveltejs/adapter-auto": "^2.0.0",
1717
"@sveltejs/kit": "^1.5.0",
18+
"@testing-library/jest-dom": "^5.16.5",
19+
"@testing-library/svelte": "^3.2.2",
20+
"@types/jest": "^29.5.1",
21+
"jest": "^29.5.0",
22+
"jest-environment-jsdom": "^29.5.0",
1823
"prettier": "^2.8.0",
1924
"prettier-plugin-svelte": "^2.8.1",
2025
"svelte": "^3.54.0",
2126
"svelte-check": "^3.0.1",
27+
"svelte-jester": "^2.3.2",
28+
"ts-jest": "^29.1.0",
29+
"ts-node": "^10.9.1",
2230
"tslib": "^2.4.1",
2331
"typescript": "^5.0.0",
24-
"vite": "^4.3.0",
25-
"vitest": "^0.25.3"
32+
"vite": "^4.3.0"
2633
},
27-
"type": "module"
34+
"type": "module",
35+
"jest": {
36+
"transform": {
37+
".(ts|tsx)": "ts-jest"
38+
},
39+
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
40+
"moduleFileExtensions": [
41+
"ts",
42+
"tsx",
43+
"js"
44+
]
45+
}
2846
}

packages/ui/src/index.test.ts packages/ui/src/__tests__/index.test.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { describe, it, expect } from 'vitest';
1+
/**
2+
* @jest-environment jsdom
3+
*/
4+
5+
import "@testing-library/jest-dom";
26

37
describe('sum test', () => {
48
it('adds 1 + 2 to equal 3', () => {

packages/ui/src/jest.config.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/** @type {import('jest').Config} */
2+
const config = {
3+
verbose: true,
4+
};
5+
6+
module.exports = config;

packages/ui/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"skipLibCheck": true,
1010
"sourceMap": true,
1111
"strict": true
12-
}
12+
},
13+
"include": ["./src/**/*.tsx", "./src/**/*.ts", "src/jest.config.ts"]
1314
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
1415
//
1516
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes

0 commit comments

Comments
 (0)