Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit ea81571

Browse files
test: replace jest with vitest (#1315)
Closes #1314. ### Summary of Changes Use `vitest` instead of `jest` as the testing framework. --------- Co-authored-by: megalinter-bot <[email protected]>
1 parent d9c6f31 commit ea81571

29 files changed

+8833
-14821
lines changed

.eslintrc.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,5 @@ module.exports = {
44
tsconfigRootDir: __dirname,
55
project: 'tsconfig.eslint.json',
66
},
7-
settings: {
8-
jest: {
9-
version: 27,
10-
},
11-
},
127
extends: '@lars-reimann',
138
};

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
- name: Install dependencies
8484
run: npm ci
8585

86-
- name: Test with Jest
86+
- name: Test with Vitest
8787
run: npm run test-with-coverage
8888

8989
- name: Upload coverage to Codecov

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
- name: Install dependencies
8686
run: npm ci
8787

88-
- name: Test with Jest
88+
- name: Test with Vitest
8989
run: npm run test-with-coverage
9090

9191
- name: Upload coverage to Codecov

api-editor/gui/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ tasks.register<NpmTask>("buildGUI") {
3535
"index.html",
3636
"package.json",
3737
"tsconfig.json",
38-
"vite.config.ts"
38+
"vite.config.ts",
3939
)
4040
outputs.dirs("dist")
4141

@@ -47,7 +47,6 @@ tasks.register<NpmTask>("testGUI") {
4747

4848
inputs.dir("src")
4949
inputs.files(
50-
"jest.config.json",
5150
"package.json",
5251
"tsconfig.json",
5352
)

api-editor/gui/jest.config.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

api-editor/gui/package-lock.json

Lines changed: 8131 additions & 14393 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api-editor/gui/package.json

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"dev": "vite",
77
"build": "tsc && vite build",
88
"serve": "vite preview",
9-
"test": "jest src",
10-
"test-with-coverage": "jest src --coverage",
9+
"test": "vitest src",
10+
"test-with-coverage": "vitest src --coverage",
1111
"gen:theme-typings": "chakra-cli tokens src/theme/index.ts",
1212
"postinstall": "npm run gen:theme-typings"
1313
},
@@ -46,9 +46,6 @@
4646
"@chakra-ui/cli": "^2.3.0",
4747
"@hookform/devtools": "^4.3.1",
4848
"@lars-reimann/prettier-config": "^5.0.0",
49-
"@testing-library/jest-dom": "^5.16.5",
50-
"@testing-library/react": "^14.0.0",
51-
"@types/jest": "^28.1.6",
5249
"@types/node-fetch": "^2.6.2",
5350
"@types/react": "^18.0.31",
5451
"@types/react-dom": "^18.0.11",
@@ -57,10 +54,10 @@
5754
"@types/react-window": "^1.8.4",
5855
"@types/uuid": "^9.0.1",
5956
"@vitejs/plugin-react": "^3.1.0",
60-
"jest": "^28.1.3",
57+
"@vitest/coverage-c8": "^0.29.8",
6158
"node-fetch": "^2.6.7",
62-
"ts-jest": "^28.0.7",
6359
"typescript": "^5.0.3",
64-
"vite": "^4.2.1"
60+
"vite": "^4.2.1",
61+
"vitest": "^0.29.8"
6562
}
6663
}

api-editor/gui/src/common/util/listOperations.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { groupBy, isEmptyList } from './listOperations';
2+
import { expect, test } from 'vitest';
23

34
test('isEmptyList returns true for empty lists', () => {
4-
expect(isEmptyList([])).toBe(true);
5+
expect(isEmptyList([])).toBeTruthy();
56
});
67

78
test('isEmptyLists returns false for non-empty lists', () => {
8-
expect(isEmptyList([1])).toBe(false);
9+
expect(isEmptyList([1])).toBeFalsy();
910
});
1011

1112
test('groupBy with empty list', () => {

api-editor/gui/src/common/util/stringOperations.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import { pluralize, truncate } from './stringOperations';
2+
import { expect, it, describe } from 'vitest';
23

34
describe('truncate', () => {
4-
test('should return strings with at most max length unchanged', () => {
5+
it('should return strings with at most max length unchanged', () => {
56
expect(truncate('Lorem ipsum', 11)).toBe('Lorem ipsum');
67
});
78

8-
test('should truncate strings longer than max length and append ...', () => {
9+
it('should truncate strings longer than max length and append ...', () => {
910
expect(truncate('Lorem ipsum', 10)).toBe('Lorem ips\u2026');
1011
});
1112
});
1213

1314
describe('pluralize', () => {
14-
test('should return singular if count is count', () => {
15+
it('should return singular if count is count', () => {
1516
expect(pluralize(1, 'thing')).toBe('1 thing');
1617
});
1718

18-
test('should return plural otherwise', () => {
19+
it('should return plural otherwise', () => {
1920
expect(pluralize(0, 'thing')).toBe('0 things');
2021
expect(pluralize(2, 'thing')).toBe('2 things');
2122
});
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,37 @@
11
import { isValidJsonFile, isValidPythonIdentifier } from './validation';
2+
import { expect, test } from 'vitest';
23

34
test('valid name starting with lower case letter', () => {
45
const testString = 'hallo_welt';
5-
expect(isValidPythonIdentifier(testString)).toBe(true);
6+
expect(isValidPythonIdentifier(testString)).toBeTruthy();
67
});
78

89
test('valid name starting with _', () => {
910
const testString = '_hallo_welt';
10-
expect(isValidPythonIdentifier(testString)).toBe(true);
11+
expect(isValidPythonIdentifier(testString)).toBeTruthy();
1112
});
1213

1314
test('valid name starting with upper case letter', () => {
1415
const testString = 'Hallo_welt';
15-
expect(isValidPythonIdentifier(testString)).toBe(true);
16+
expect(isValidPythonIdentifier(testString)).toBeTruthy();
1617
});
1718

1819
test('invalid name with %', () => {
1920
const testString = 'Hallo%welt';
20-
expect(isValidPythonIdentifier(testString)).toBe(false);
21+
expect(isValidPythonIdentifier(testString)).toBeFalsy();
2122
});
2223

2324
test('invalid name starting with number', () => {
2425
const testString = '9Hallo_Welt';
25-
expect(isValidPythonIdentifier(testString)).toBe(false);
26+
expect(isValidPythonIdentifier(testString)).toBeFalsy();
2627
});
2728

2829
test('invalid json file name', () => {
2930
const testString = 'helloWorld.png';
30-
expect(isValidJsonFile(testString)).toBe(false);
31+
expect(isValidJsonFile(testString)).toBeFalsy();
3132
});
3233

3334
test('valid json file name', () => {
3435
const testString = 'helloWorld.json';
35-
expect(isValidJsonFile(testString)).toBe(true);
36+
expect(isValidJsonFile(testString)).toBeTruthy();
3637
});

0 commit comments

Comments
 (0)