Skip to content

Commit

Permalink
🔧 chore: 从 jest 迁移到 vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Apr 9, 2023
1 parent 05c9ce9 commit 860f87f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 42 deletions.
28 changes: 0 additions & 28 deletions jest.config.ts

This file was deleted.

17 changes: 6 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
"release": "semantic-release",
"setup": "dumi setup",
"start": "dumi dev",
"test": "jest --passWithNoTests",
"test:coverage": "jest --coverage --passWithNoTests",
"test:update": "jest --update-snapshot",
"test": "vitest",
"test:coverage": "vitest run --coverage",
"test:update": "vitest -u",
"type-check": "tsc -p tsconfig-check.json"
},
"lint-staged": {
Expand All @@ -61,14 +61,11 @@
},
"devDependencies": {
"@commitlint/cli": "^17",
"@testing-library/jest-dom": "^5",
"@testing-library/react": "^13",
"@types/jest": "^27",
"@types/react": "^18",
"@types/react-dom": "^18",
"@types/testing-library__jest-dom": "^5",
"@umijs/lint": "^4",
"@umijs/test": "^4",
"@vitest/coverage-c8": "latest",
"antd": "^5",
"commitlint": "^17",
"commitlint-config-gitmoji": "^2",
Expand All @@ -80,8 +77,7 @@
"eslint-import-resolver-typescript": "^2",
"father": "^4",
"husky": "^8",
"jest": "^29",
"jest-environment-jsdom": "^29",
"jsdom": "^21",
"lint-staged": "^13",
"prettier": "^2",
"prettier-plugin-organize-imports": "^3",
Expand All @@ -91,9 +87,8 @@
"semantic-release": "^20",
"semantic-release-config-gitmoji": "^1",
"stylelint": "^14",
"ts-jest": "^29",
"ts-node": "^10",
"typescript": "^4",
"vitest": "latest",
"zustand": "^4"
},
"peerDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions tests/context.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
useEffect,
useState,
} from 'react';
import { vi } from 'vitest';
import type { StoreApi } from 'zustand';
import { create } from 'zustand';
import { createContext } from 'zustand-utils';
Expand Down Expand Up @@ -122,7 +123,7 @@ it('uses context store api', async () => {
});

it('throws error when not using provider', async () => {
console.error = jest.fn();
console.error = vi.fn();

class ErrorBoundary extends ClassComponent<
{ children?: ReactNode | undefined },
Expand Down Expand Up @@ -157,7 +158,7 @@ it('throws error when not using provider', async () => {
});

it('throws error useStoreApi when not using provider', async () => {
console.error = jest.fn();
console.error = vi.fn();

class ErrorBoundary extends ClassComponent<
{ children?: ReactNode | undefined },
Expand Down
1 change: 0 additions & 1 deletion tests/jest-setup.ts

This file was deleted.

Empty file added tests/test-setup.ts
Empty file.
16 changes: 16 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { defineConfig } from 'vitest/config';

export default defineConfig({
esbuild: {
jsxInject: "import React from 'react'",
},
test: {
setupFiles: './tests/test-setup.ts',
environment: 'jsdom',
globals: true,
alias: {
'@': './src',
'zustand-utils': './src',
},
},
});

0 comments on commit 860f87f

Please sign in to comment.