Skip to content

Commit bd5f3c3

Browse files
committed
test: replace Jest with Vitest
1 parent 258c5e7 commit bd5f3c3

12 files changed

+25
-39
lines changed

.eslintrc.yml

-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,5 @@ extends:
33
- cheminfo-typescript
44
- cheminfo-typescript/jsdoc
55
- cheminfo-typescript/unicorn
6-
plugins:
7-
- jest
86
rules:
97
'@typescript-eslint/restrict-template-expressions': off
10-
'jest/no-focused-tests': 'error'

jest.config.js

-11
This file was deleted.

package.json

+4-9
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"prettier": "prettier --check src demo",
2929
"prettier-write": "prettier --write src demo",
3030
"test": "npm run test-only && npm run eslint && npm run prettier && npm run check-types",
31-
"test-only": "cross-env JEST_IMAGE_SNAPSHOT_TRACK_OBSOLETE=1 jest",
31+
"test-only": "cross-env JEST_IMAGE_SNAPSHOT_TRACK_OBSOLETE=1 vitest run --coverage",
3232
"tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm",
3333
"tsc-cjs": "tsc --project tsconfig.cjs.json",
3434
"tsc-esm": "tsc --project tsconfig.esm.json"
@@ -41,9 +41,6 @@
4141
"url": "https://github.com/image-js/image-js/issues"
4242
},
4343
"homepage": "https://github.com/image-js/image-js#readme",
44-
"overrides": {
45-
"jest": "$jest"
46-
},
4744
"dependencies": {
4845
"bresenham-zingl": "^0.1.1",
4946
"colord": "^2.9.3",
@@ -62,24 +59,22 @@
6259
"devDependencies": {
6360
"@microsoft/api-extractor": "^7.34.8",
6461
"@tailwindcss/forms": "^0.5.3",
65-
"@types/jest": "^29.5.1",
6662
"@types/jest-image-snapshot": "^6.1.0",
6763
"@types/node": "^20.1.2",
6864
"@types/picomatch": "^2.3.0",
6965
"@types/react": "^18.2.6",
7066
"@types/react-dom": "^18.2.4",
7167
"@types/robust-point-in-polygon": "^1.0.2",
7268
"@vitejs/plugin-react": "^4.0.0",
69+
"@vitest/coverage-c8": "^0.31.0",
7370
"autoprefixer": "^10.4.14",
7471
"clsx": "^1.2.1",
7572
"cross-env": "^7.0.3",
7673
"eslint": "^8.40.0",
7774
"eslint-config-cheminfo-react": "^9.1.0",
7875
"eslint-config-cheminfo-typescript": "^11.3.1",
7976
"eslint-plugin-import": "^2.27.5",
80-
"eslint-plugin-jest": "^27.2.1",
8177
"immer": "^10.0.2",
82-
"jest": "^29.5.0",
8378
"jest-image-snapshot": "^6.1.0",
8479
"jest-matcher-deep-close-to": "^3.0.2",
8580
"postcss": "^8.4.23",
@@ -89,8 +84,8 @@
8984
"react-router-dom": "^6.11.1",
9085
"rimraf": "^5.0.0",
9186
"tailwindcss": "^3.3.2",
92-
"ts-jest": "^29.1.0",
9387
"typescript": "^5.0.4",
94-
"vite": "^4.3.5"
88+
"vite": "^4.3.5",
89+
"vitest": "^0.31.0"
9590
}
9691
}

src/__tests__/__snapshots__/Image.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`check custom inspect with image too large 1`] = `
44
"Image {

src/__tests__/__snapshots__/Mask.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`check custom inspect 1`] = `
44
"Mask {

src/maskAnalysis/utils/__tests__/getAngle.test.ts

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import { toBeDeepCloseTo } from 'jest-matcher-deep-close-to';
2-
31
import { getAngle, getClockwiseAngle } from '../getAngle';
42

5-
expect.extend({ toBeDeepCloseTo });
6-
73
test.each([
84
[
95
'-60 degrees',

src/roi/__tests__/__snapshots__/computeRois.test.ts.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Jest Snapshot v1, https://goo.gl/fbAQLP
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

33
exports[`3x3 mask 1`] = `
44
[

src/roi/__tests__/borderLengths.test.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { test } from 'vitest';
2+
13
import { fromMask, RoiKind } from '../..';
24

35
test('border lengths property 5x5', () => {
@@ -17,7 +19,7 @@ test('border lengths property 5x5', () => {
1719
]);
1820
});
1921

20-
test.skip.failing('border lengths property 4x4', () => {
22+
test.skip('border lengths property 4x4', () => {
2123
const mask = testUtils.createMask([
2224
[0, 1, 1, 1],
2325
[0, 1, 0, 1],

tsconfig.cjs.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,5 @@
55
"declaration": true,
66
"declarationMap": true
77
},
8-
"exclude": [
9-
"./demo/**/*",
10-
"./src/**/__tests__",
11-
"./jest.setup.ts",
12-
"./test/**/*",
13-
"vite.config.ts"
14-
]
8+
"exclude": ["./demo/**/*", "./src/**/__tests__", "./test/**/*", "vite*.ts"]
159
}

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
"jsx": "react-jsx",
1111
"useUnknownInCatchVariables": false
1212
},
13-
"include": ["./demo/**/*", "./jest.setup.ts", "./src/**/*", "./test/**/*"]
13+
"include": ["./demo/**/*", "./src/**/*", "./test/**/*", "vite*.ts"]
1414
}

vitest.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineConfig } from 'vitest/config';
2+
3+
export default defineConfig({
4+
test: {
5+
globals: true,
6+
setupFiles: ['./vitest.setup.ts'],
7+
reporters: [
8+
'default',
9+
'jest-image-snapshot/src/outdated-snapshot-reporter.js',
10+
],
11+
},
12+
});

jest.setup.ts vitest.setup.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { toBeDeepCloseTo, toMatchCloseTo } from 'jest-matcher-deep-close-to';
2+
import { expect } from 'vitest';
23

34
import * as jestMatchers from './test/jestMatchers';
45
import * as testUtils from './test/testUtils';

0 commit comments

Comments
 (0)