Skip to content

Commit c43ad93

Browse files
committedDec 30, 2024
chore: update jest to 0.29
1 parent 9b57b87 commit c43ad93

File tree

16 files changed

+1643
-3048
lines changed

16 files changed

+1643
-3048
lines changed
 

‎common/config/rush/pnpm-lock.yaml

+1,455-2,954
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/calculator/jest.config.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const path = require('path');
2+
const baseJestConfig = require('@internal/jest-config/jest.base');
3+
4+
module.exports = {
5+
...baseJestConfig,
6+
moduleNameMapper: {
7+
...baseJestConfig.moduleNameMapper
8+
}
9+
};

‎packages/calculator/jest.config.ts

-32
This file was deleted.

‎packages/calculator/package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,17 @@
3232
"@visactor/vutils": "~0.17.4"
3333
},
3434
"devDependencies": {
35-
"@types/jest": "^26.0.0",
35+
"@internal/jest-config": "workspace:*",
36+
"@types/jest": "~29.5.0",
37+
"jest": "~29.5.0",
38+
"jest-environment-jsdom": "~29.5.0",
39+
"@jest/globals": "~29.5.0",
40+
"ts-jest": "~29.2.5",
3641
"@typescript-eslint/eslint-plugin": "5.30.0",
3742
"@typescript-eslint/parser": "5.30.0",
3843
"@types/node": "*",
39-
"jest": "^26.0.0",
4044
"npm-run-all": "^4.1.5",
4145
"rimraf": "^3.0.2",
42-
"ts-jest": "^26.0.0",
4346
"ts-node": "10.9.0",
4447
"typescript": "4.9.5",
4548
"@internal/ts-config": "workspace:*",

‎packages/chart-advisor/jest.config.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const path = require('path');
2+
const baseJestConfig = require('@internal/jest-config/jest.base');
3+
4+
module.exports = {
5+
...baseJestConfig,
6+
moduleNameMapper: {
7+
...baseJestConfig.moduleNameMapper
8+
}
9+
};

‎packages/chart-advisor/package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@
3333
"@visactor/vutils": "~0.17.4"
3434
},
3535
"devDependencies": {
36-
"@types/jest": "^26.0.0",
36+
"@internal/jest-config": "workspace:*",
37+
"@types/jest": "~29.5.0",
38+
"jest": "~29.5.0",
39+
"jest-environment-jsdom": "~29.5.0",
40+
"@jest/globals": "~29.5.0",
41+
"ts-jest": "~29.2.5",
3742
"@types/node": "*",
38-
"jest": "^26.0.0",
39-
"ts-jest": "^26.0.0",
4043
"typescript": "4.9.5",
4144
"undici-types": "^5.27.2",
4245
"@typescript-eslint/eslint-plugin": "5.30.0",

‎packages/vmind/__tests__/performance/performanceTest.ts ‎packages/vmind/__tests__/performance/performance.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const testPerformance = (model: Model, vmind: VMind) => {
8585
} else {
8686
error('fail to generate with LLM!');
8787
}
88-
done();
88+
// done();
8989
});
9090
}
9191
modelResultMap[model].totalCount += 1;
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "@internal/ts-config/tsconfig.base.json",
3+
"include": ["./", "../src"],
4+
"compilerOptions": {
5+
"paths": {
6+
"@visactor/calculator": ["../../calculator/src"],
7+
"@visactor/chart-advisor": ["../../chart-advisor/src"]
8+
},
9+
"lib": ["DOM", "ESNext"]
10+
},
11+
"references": []
12+
}

‎packages/vmind/jest.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
const path = require('path');
2+
const baseJestConfig = require('@internal/jest-config/jest.base');
3+
14
module.exports = {
5+
<<<<<<< Updated upstream
26
preset: 'ts-jest',
37
runner: 'jest-electron/runner',
48
testEnvironment: 'jest-electron/environment',
@@ -29,4 +33,10 @@ module.exports = {
2933
'!**/interface.ts',
3034
'!**/vite/**'
3135
]
36+
=======
37+
...baseJestConfig,
38+
moduleNameMapper: {
39+
...baseJestConfig.moduleNameMapper
40+
}
41+
>>>>>>> Stashed changes
3242
};
+31-17
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,37 @@
1+
const path = require('path');
2+
const baseJestConfig = require('@internal/jest-config/jest.base');
3+
14
module.exports = {
2-
preset: 'ts-jest',
3-
silent: false,
4-
globals: {
5-
'ts-jest': {
6-
resolveJsonModule: true,
7-
esModuleInterop: true,
8-
experimentalDecorators: true,
9-
module: 'ESNext',
10-
tsconfig: './tsconfig.test.json'
11-
}
12-
},
13-
testTimeout: 60000,
5+
...baseJestConfig,
146
moduleNameMapper: {
15-
axios: 'axios/dist/node/axios.cjs',
16-
'd3-hierarchy': 'd3-hierarchy/dist/d3-hierarchy.min.js',
17-
'^src/(.*)$': '<rootDir>/src/$1',
7+
...baseJestConfig.moduleNameMapper,
8+
axios: path.resolve(__dirname, 'node_modules/axios/dist/node/axios.cjs')
189
},
1910
verbose: true,
2011
// 在测试之前设置环境变量
21-
setupFiles: ['./test-setup.js'],
22-
testEnvironment: 'node'
12+
setupFiles: ['./test-setup.js']
2313
};
14+
15+
// module.exports = {
16+
// preset: 'ts-jest',
17+
// silent: false,
18+
// globals: {
19+
// 'ts-jest': {
20+
// resolveJsonModule: true,
21+
// esModuleInterop: true,
22+
// experimentalDecorators: true,
23+
// module: 'ESNext',
24+
// tsconfig: './tsconfig.test.json'
25+
// }
26+
// },
27+
// testTimeout: 60000,
28+
// moduleNameMapper: {
29+
// axios: 'axios/dist/node/axios.cjs',
30+
// 'd3-hierarchy': 'd3-hierarchy/dist/d3-hierarchy.min.js',
31+
// '^src/(.*)$': '<rootDir>/src/$1'
32+
// },
33+
// verbose: true,
34+
// // 在测试之前设置环境变量
35+
// setupFiles: ['./test-setup.js'],
36+
// testEnvironment: 'node'
37+
// };

‎packages/vmind/package.json

+9-5
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
3939
"preview": "vite ./__tests__/browser preview",
4040
"clear": "rm -rf build && rm -rf esm && rm -rf cjs",
41-
"test": "jest",
41+
"test": "jest ./__tests__/unit/",
4242
"test-cov": "jest -w 16 --coverage",
4343
"test-live": "npm run test-watch __tests__/unit/",
4444
"test-watch": "DEBUG_MODE=1 jest --watch",
45-
"test-performance": "jest ./__tests__/performance/performanceTest.ts --config jest.performance.config.js",
45+
"test-performance": "jest ./__tests__/performance/performance.test.ts --config jest.performance.config.js",
4646
"prepublishOnly": "npm run build",
4747
"postpublish": "npm run clear",
4848
"release-minor": "npm version minor && npm publish && git commit -a -m 'chore: release minor version for vmind' && git push",
@@ -58,8 +58,9 @@
5858
"@internal/bundler": "workspace:*",
5959
"@internal/eslint-config": "workspace:*",
6060
"@internal/ts-config": "workspace:*",
61+
"@internal/jest-config": "workspace:*",
6162
"@arco-design/web-react": "2.46.1",
62-
"@types/jest": "^26.0.0",
63+
"@types/jest": "~29.5.0",
6364
"@types/react": "^18.0.0",
6465
"@types/react-dom": "^18.0.0",
6566
"@typescript-eslint/eslint-plugin": "5.30.0",
@@ -74,8 +75,11 @@
7475
"eslint-plugin-react": "7.30.1",
7576
"typescript": "4.9.5",
7677
"vite": "3.2.6",
77-
"jest": "^26.0.0",
78-
"jest-electron": "^0.1.12",
78+
"jest": "~29.5.0",
79+
"util": "~0.12.5",
80+
"jest-environment-jsdom": "~29.5.0",
81+
"@jest/globals": "~29.5.0",
82+
"ts-jest": "~29.2.5",
7983
"react": "^18.0.0",
8084
"react-dom": "^18.0.0",
8185
"react-router-dom": "6.9.0",

‎packages/vmind/src/atom/dataQuery/executeQuery.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import alasql from 'alasql';
2-
import type { DataQueryCtx, DataTable, FieldInfo } from 'src/types';
2+
import type { DataQueryCtx, DataTable, FieldInfo } from '../../types';
33
import {
44
matchColumnName,
55
parseRespondField,

‎packages/vmind/test-setup.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require('dotenv').config({ path: './.env.local' });
2-
const { error, log,warn,info,debug } = require('console');
2+
const { error, log, warn, info, debug } = require('console');
33

44
global.console = {
55
// eslint-disable-next-line no-undef
@@ -12,3 +12,6 @@ global.console = {
1212
info: jest.fn(),
1313
debug: jest.fn()
1414
};
15+
16+
global.TextEncoder = require('util').TextEncoder;
17+
global.TextDecoder = require('util').TextDecoder;

‎rush.json

+16-31
Original file line numberDiff line numberDiff line change
@@ -17,79 +17,64 @@
1717
"defaultBranch": "main",
1818
"defaultRemote": "origin"
1919
},
20-
"allowedProjectTags": [
21-
"tool",
22-
"share",
23-
"package",
24-
"doc"
25-
],
20+
"allowedProjectTags": ["tool", "share", "package", "doc"],
2621
"projects": [
2722
{
2823
"packageName": "@internal/bundler",
2924
"projectFolder": "tools/bundler",
30-
"tags": [
31-
"tool"
32-
],
25+
"tags": ["tool"],
3326
"shouldPublish": false
3427
},
3528
{
3629
"packageName": "@internal/typescript-json-schema",
3730
"projectFolder": "tools/typescript-json-schema",
38-
"tags": [
39-
"tool"
40-
],
31+
"tags": ["tool"],
4132
"shouldPublish": false
4233
},
4334
{
4435
"packageName": "@internal/eslint-config",
4536
"projectFolder": "share/eslint-config",
46-
"tags": [
47-
"share"
48-
],
37+
"tags": ["share"],
38+
"shouldPublish": false
39+
},
40+
{
41+
"packageName": "@internal/jest-config",
42+
"projectFolder": "share/jest-config",
43+
"tags": ["share"],
4944
"shouldPublish": false
5045
},
5146
{
5247
"packageName": "@internal/ts-config",
5348
"projectFolder": "share/ts-config",
54-
"tags": [
55-
"share"
56-
],
49+
"tags": ["share"],
5750
"shouldPublish": false
5851
},
5952
{
6053
"packageName": "@internal/docs",
6154
"projectFolder": "docs",
62-
"tags": [
63-
"doc"
64-
],
55+
"tags": ["doc"],
6556
"shouldPublish": false
6657
},
6758
{
6859
"packageName": "@visactor/vmind",
6960
"projectFolder": "packages/vmind",
7061
"shouldPublish": true,
7162
"versionPolicyName": "vmindMin",
72-
"tags": [
73-
"package"
74-
]
63+
"tags": ["package"]
7564
},
7665
{
7766
"packageName": "@visactor/calculator",
7867
"projectFolder": "packages/calculator",
7968
"shouldPublish": true,
8069
"versionPolicyName": "vmindMin",
81-
"tags": [
82-
"package"
83-
]
70+
"tags": ["package"]
8471
},
8572
{
8673
"packageName": "@visactor/chart-advisor",
8774
"projectFolder": "packages/chart-advisor",
8875
"shouldPublish": true,
8976
"versionPolicyName": "vmindMin",
90-
"tags": [
91-
"package"
92-
]
77+
"tags": ["package"]
9378
}
9479
]
95-
}
80+
}

‎share/jest-config/jest.base.js

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
preset: 'ts-jest',
5+
testEnvironment: 'jsdom',
6+
testTimeout: 30000,
7+
silent: true,
8+
testMatch: ['**/__tests__/**/*.test.[jt]s'],
9+
transform: {
10+
'^.+\\.ts?$': [
11+
'ts-jest',
12+
{
13+
resolveJsonModule: true,
14+
esModuleInterop: true,
15+
experimentalDecorators: true,
16+
module: 'ESNext',
17+
tsconfig: '<rootDir>/__tests__/tsconfig.json'
18+
// ts-jest configuration goes here
19+
}
20+
]
21+
},
22+
globals: {
23+
__VERSION__: JSON.stringify('test'),
24+
__DEV__: JSON.stringify(true)
25+
},
26+
verbose: false,
27+
moduleNameMapper: {
28+
'^src/(.*)$': '<rootDir>/src/$1'
29+
// 'd3-color': path.resolve(__dirname, './node_modules/d3-color/dist/d3-color.min.js'),
30+
// 'd3-array': path.resolve(__dirname, './node_modules/d3-array/dist/d3-array.min.js')
31+
},
32+
coverageDirectory: 'coverage',
33+
coverageProvider: 'v8',
34+
coverageReporters: ['json-summary', 'lcov', 'text'],
35+
collectCoverageFrom: [
36+
'**/src/**',
37+
'!.rollup.cache/**',
38+
'!**/cjs/**',
39+
'!**/dist/**',
40+
'!**/es/**',
41+
'!**/node_modules/**',
42+
'!**/__tests__/**',
43+
'!**/types/**',
44+
'!**/interface.ts',
45+
'!**/*.d.ts'
46+
],
47+
coverageThreshold: {
48+
global: {
49+
branches: 80,
50+
functions: 80,
51+
lines: 80,
52+
statements: 80
53+
}
54+
}
55+
};

‎share/jest-config/package.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@internal/jest-config",
3+
"private": true,
4+
"version": "0.0.1",
5+
"dependencies": {
6+
"jsdom": "~22.1.0",
7+
"@jest/globals": "~29.5.0",
8+
"jest-environment-jsdom": "~29.5.0"
9+
},
10+
"devDependencies": {
11+
"jest": "~29.5.0",
12+
"@types/jest": "~29.5.0",
13+
"typescript": "4.9.5"
14+
},
15+
"peerDependencies": {
16+
"jest": "~29.5.0",
17+
"typescript": "4.3 - 6.x"
18+
}
19+
}

0 commit comments

Comments
 (0)
Please sign in to comment.