Skip to content

Commit

Permalink
test: replace Jest with Vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
targos committed May 10, 2023
1 parent 258c5e7 commit bd5f3c3
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 39 deletions.
3 changes: 0 additions & 3 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,5 @@ extends:
- cheminfo-typescript
- cheminfo-typescript/jsdoc
- cheminfo-typescript/unicorn
plugins:
- jest
rules:
'@typescript-eslint/restrict-template-expressions': off
'jest/no-focused-tests': 'error'
11 changes: 0 additions & 11 deletions jest.config.js

This file was deleted.

13 changes: 4 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"prettier": "prettier --check src demo",
"prettier-write": "prettier --write src demo",
"test": "npm run test-only && npm run eslint && npm run prettier && npm run check-types",
"test-only": "cross-env JEST_IMAGE_SNAPSHOT_TRACK_OBSOLETE=1 jest",
"test-only": "cross-env JEST_IMAGE_SNAPSHOT_TRACK_OBSOLETE=1 vitest run --coverage",
"tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm",
"tsc-cjs": "tsc --project tsconfig.cjs.json",
"tsc-esm": "tsc --project tsconfig.esm.json"
Expand All @@ -41,9 +41,6 @@
"url": "https://github.com/image-js/image-js/issues"
},
"homepage": "https://github.com/image-js/image-js#readme",
"overrides": {
"jest": "$jest"
},
"dependencies": {
"bresenham-zingl": "^0.1.1",
"colord": "^2.9.3",
Expand All @@ -62,24 +59,22 @@
"devDependencies": {
"@microsoft/api-extractor": "^7.34.8",
"@tailwindcss/forms": "^0.5.3",
"@types/jest": "^29.5.1",
"@types/jest-image-snapshot": "^6.1.0",
"@types/node": "^20.1.2",
"@types/picomatch": "^2.3.0",
"@types/react": "^18.2.6",
"@types/react-dom": "^18.2.4",
"@types/robust-point-in-polygon": "^1.0.2",
"@vitejs/plugin-react": "^4.0.0",
"@vitest/coverage-c8": "^0.31.0",
"autoprefixer": "^10.4.14",
"clsx": "^1.2.1",
"cross-env": "^7.0.3",
"eslint": "^8.40.0",
"eslint-config-cheminfo-react": "^9.1.0",
"eslint-config-cheminfo-typescript": "^11.3.1",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"immer": "^10.0.2",
"jest": "^29.5.0",
"jest-image-snapshot": "^6.1.0",
"jest-matcher-deep-close-to": "^3.0.2",
"postcss": "^8.4.23",
Expand All @@ -89,8 +84,8 @@
"react-router-dom": "^6.11.1",
"rimraf": "^5.0.0",
"tailwindcss": "^3.3.2",
"ts-jest": "^29.1.0",
"typescript": "^5.0.4",
"vite": "^4.3.5"
"vite": "^4.3.5",
"vitest": "^0.31.0"
}
}
2 changes: 1 addition & 1 deletion src/__tests__/__snapshots__/Image.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`check custom inspect with image too large 1`] = `
"Image {
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/__snapshots__/Mask.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`check custom inspect 1`] = `
"Mask {
Expand Down
4 changes: 0 additions & 4 deletions src/maskAnalysis/utils/__tests__/getAngle.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { toBeDeepCloseTo } from 'jest-matcher-deep-close-to';

import { getAngle, getClockwiseAngle } from '../getAngle';

expect.extend({ toBeDeepCloseTo });

test.each([
[
'-60 degrees',
Expand Down
2 changes: 1 addition & 1 deletion src/roi/__tests__/__snapshots__/computeRois.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`3x3 mask 1`] = `
[
Expand Down
4 changes: 3 additions & 1 deletion src/roi/__tests__/borderLengths.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { test } from 'vitest';

import { fromMask, RoiKind } from '../..';

test('border lengths property 5x5', () => {
Expand All @@ -17,7 +19,7 @@ test('border lengths property 5x5', () => {
]);
});

test.skip.failing('border lengths property 4x4', () => {
test.skip('border lengths property 4x4', () => {
const mask = testUtils.createMask([
[0, 1, 1, 1],
[0, 1, 0, 1],
Expand Down
8 changes: 1 addition & 7 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,5 @@
"declaration": true,
"declarationMap": true
},
"exclude": [
"./demo/**/*",
"./src/**/__tests__",
"./jest.setup.ts",
"./test/**/*",
"vite.config.ts"
]
"exclude": ["./demo/**/*", "./src/**/__tests__", "./test/**/*", "vite*.ts"]
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"jsx": "react-jsx",
"useUnknownInCatchVariables": false
},
"include": ["./demo/**/*", "./jest.setup.ts", "./src/**/*", "./test/**/*"]
"include": ["./demo/**/*", "./src/**/*", "./test/**/*", "vite*.ts"]
}
12 changes: 12 additions & 0 deletions vitest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
globals: true,
setupFiles: ['./vitest.setup.ts'],
reporters: [
'default',
'jest-image-snapshot/src/outdated-snapshot-reporter.js',
],
},
});
1 change: 1 addition & 0 deletions jest.setup.ts → vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { toBeDeepCloseTo, toMatchCloseTo } from 'jest-matcher-deep-close-to';
import { expect } from 'vitest';

import * as jestMatchers from './test/jestMatchers';
import * as testUtils from './test/testUtils';
Expand Down

0 comments on commit bd5f3c3

Please sign in to comment.