Skip to content

Commit

Permalink
feat: replace jest with vitest (#2568)
Browse files Browse the repository at this point in the history
  • Loading branch information
gongshun authored Jul 31, 2023
1 parent 197699f commit d037bb4
Show file tree
Hide file tree
Showing 13 changed files with 12,419 additions and 11,171 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
root: true,
extends: [require.resolve('@umijs/fabric/dist/eslint')],
rules: {
'@typescript-eslint/prefer-interface': 0,
Expand Down
29 changes: 3 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,23 @@
"docs": "dumi dev",
"build-docs": "dumi build",
"ci": "pnpm run lint && pnpm run build && pnpm run test",
"test": "cross-env NODE_ENV=test jest",
"test": "cross-env NODE_ENV=test vitest",
"prepare": "husky install"
},
"devDependencies": {
"@changesets/cli": "^2.26.1",
"@jest/types": "^27.5.1",
"@umijs/fabric": "^2.0.7",
"cross-env": "^7.0.2",
"dumi": "^1.1.0-beta.24",
"dumi-theme-default": "^1.0.10",
"eslint": "^8.10.0",
"eslint-define-config": "^1.2.5",
"husky": "^8.0.3",
"jest": "^25.2.2",
"lint-staged": "^9.4.2",
"prettier": "^2.1.2",
"rimraf": "^3.0.0",
"ts-jest": "^25.2.1",
"umi-plugin-hire": "^1.0.3"
"umi-plugin-hire": "^1.0.3",
"vitest": "^0.32.2"
},
"repository": {
"type": "git",
Expand All @@ -55,27 +53,6 @@
"eslint --ext .ts"
]
},
"jest": {
"moduleFileExtensions": [
"js",
"ts"
],
"testMatch": [
"<rootDir>/packages/**/__tests__/**/*.test.ts"
],
"testPathIgnorePatterns": [
"/node_modules/",
"/fixtures/"
],
"transform": {
"^.+\\.ts$": "<rootDir>/node_modules/ts-jest"
},
"coveragePathIgnorePatterns": [
"/node_modules/",
"/__tests__/",
"/dist/"
]
},
"packageManager": "[email protected]",
"publishConfig": {
"registry": "https://registry.npmjs.org/"
Expand Down
2 changes: 1 addition & 1 deletion packages/loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"sideEffects": false,
"scripts": {
"build": "father build",
"test": "cross-env NODE_ENV=test jest",
"test": "cross-env NODE_ENV=test vitest",
"bench": "npm run build && tachometer ./benchmarks/parser/tern/import-html-entry.html ./benchmarks/parser/tern/parser.html --timeout=1"
},
"author": "Kuitos",
Expand Down
4 changes: 1 addition & 3 deletions packages/qiankun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"lint:prettier": "prettier -c ./src/**/*",
"prettier": "prettier --write ./src/**/*",
"ci": "yarn lint && yarn build && yarn test",
"test": "cross-env NODE_ENV=test jest"
"test": "cross-env NODE_ENV=test vitest"
},
"repository": {
"type": "git",
Expand All @@ -46,13 +46,11 @@
"single-spa": "^6.0.0-beta.3"
},
"devDependencies": {
"@types/jest": "^25.1.4",
"@types/lodash": "^4.14.129",
"@types/vfile-message": "1.x",
"babel-plugin-import": "^1.12.1",
"cross-env": "^7.0.2",
"father": "^4.1.0",
"jest": "^25.2.2",
"levenary": "^1.1.1",
"np": "^5.0.3",
"npm-run-all": "^4.1.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/sandbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"sideEffects": false,
"scripts": {
"build": "father build",
"test": "cross-env NODE_ENV=test jest"
"test": "cross-env NODE_ENV=test vitest --config ../../vitest.config.ts"
},
"files": [
"dist"
Expand Down
2 changes: 1 addition & 1 deletion packages/sandbox/src/patchers/__tests__/css.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @since 2020-04-19
*/

import { sleep } from '../../../utils';
import { sleep } from '../../utils';
import { ScopedCSS } from '../css';

let CSSProcessor: ScopedCSS;
Expand Down
8 changes: 4 additions & 4 deletions packages/sandbox/src/patchers/__tests__/interval.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* @since 2020-03-30
*/

import { sleep } from '../../../utils';
import { sleep } from '../../utils';
import patch from '../interval';

test('patch setInterval', async () => {
const free = patch(window);

const clearedListener = jest.fn();
const unclearedListener = jest.fn();
const unclearedListenerWithArgs = jest.fn();
const clearedListener = vi.fn();
const unclearedListener = vi.fn();
const unclearedListenerWithArgs = vi.fn();

const interval1 = window.setInterval(clearedListener, 60);
window.setInterval(unclearedListener, 8);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { getStyledElementCSSRules, rebuildCSSRules, recordStyledComponentsCSSRules } from '../common';

jest.mock('import-html-entry', () => ({
execScripts: jest.fn(),
vi.mock('import-html-entry', () => ({
default: {
execScripts: vi.fn(),
}
}));

const cssRuleText1 = '#foo { color: red; }';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { SandBoxType } from '../../../../interfaces';
import { noop } from 'lodash';
import { patchStandardSandbox } from '../forStrictSandbox';

jest.mock('import-html-entry', () => ({
execScripts: jest.fn(),
vi.mock('import-html-entry', () => ({
default: {
execScripts: vi.fn(),
}
}));

describe('forStrictSandbox test', () => {
Expand Down
Loading

0 comments on commit d037bb4

Please sign in to comment.