Skip to content

Commit 95fc5f0

Browse files
authored
test(vitest): use vitest instead of jest (#1124)
1 parent 7bf9f0e commit 95fc5f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2765
-6843
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules/
22
dist/
33
examples/
4+
vite.config.ts

.eslintrc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
{
22
"root": true,
3-
"plugins": [
4-
"eslint-plugin-tsdoc"
5-
],
3+
"plugins": ["eslint-plugin-tsdoc"],
64
"parserOptions": {
7-
"project": ["tsconfig.json"]
5+
"project": ["tsconfig.json"],
86
},
97
"extends": ["@scaleway/react/typescript"],
108
"rules": {
@@ -13,23 +11,29 @@
1311
"error",
1412
{
1513
"selector": "enumMember",
16-
"format": ["PascalCase"]
14+
"format": ["PascalCase"],
1715
}
1816
],
1917
"import/prefer-default-export": "off",
2018
"import/no-default-export": "error",
2119
"no-await-in-loop": "off",
22-
"@typescript-eslint/no-namespace": "off"
20+
"@typescript-eslint/no-namespace": "off",
2321
},
2422
"overrides": [
2523
{
2624
"files": [
2725
"./packages/clients/src/scw/**/*.ts",
28-
"./packages/clients/src/internal/**/*.ts"
26+
"./packages/clients/src/internal/**/*.ts",
2927
],
3028
"rules": {
31-
"@typescript-eslint/consistent-type-definitions": "off"
29+
"@typescript-eslint/consistent-type-definitions": "off",
3230
}
33-
}
34-
]
31+
},
32+
{
33+
"files": ["**/*.test.ts", "__tests__/**/*.ts", "vite.config.ts"],
34+
"rules": {
35+
"eslint-disable import/no-extraneous-dependencies": "off"
36+
},
37+
},
38+
],
3539
}

.github/workflows/check-pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Use Node.js
1414
uses: actions/[email protected]
1515
with:
16-
node-version: 18
16+
node-version: 20
1717
check-latest: true
1818
cache: "pnpm"
1919
- run: pnpm install

.github/workflows/deploy-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Use Node.js
2727
uses: actions/[email protected]
2828
with:
29-
node-version: 18
29+
node-version: 20
3030
check-latest: true
3131
- run: pnpm install
3232
- run: pnpm run build

.github/workflows/run-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Use Node.js
1717
uses: actions/[email protected]
1818
with:
19-
node-version: 18
19+
node-version: 20
2020
check-latest: true
2121
cache: "pnpm"
2222
- run: pnpm install
@@ -30,7 +30,7 @@ jobs:
3030
- name: Use Node.js
3131
uses: actions/[email protected]
3232
with:
33-
node-version: 18
33+
node-version: 20
3434
check-latest: true
3535
cache: "pnpm"
3636
- run: pnpm install
@@ -45,7 +45,7 @@ jobs:
4545
- jsdom
4646
node:
4747
- "18"
48-
- "19"
48+
- "20"
4949
steps:
5050
- uses: actions/[email protected]
5151
- uses: pnpm/[email protected]
@@ -57,5 +57,5 @@ jobs:
5757
cache: "pnpm"
5858
- run: pnpm install
5959
- run: pnpm run build
60-
- run: pnpm run test:coverage --testEnvironment ${{ matrix.test-environment }}
60+
- run: pnpm run test:coverage --environment ${{ matrix.test-environment }}
6161
- uses: codecov/[email protected]

env-setup.ts

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

package.json

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,27 @@
1010
},
1111
"type": "module",
1212
"scripts": {
13-
"build": "lerna exec --stream -- rollup -c ../../rollup.config.mjs",
13+
"build": "pnpm recursive exec -- rollup -c ../../rollup.config.mjs",
1414
"build:profile": "cross-env PROFILE=true pnpm run build",
1515
"commit": "npx git-cz -a",
1616
"doc": "typedoc",
1717
"format": "prettier --write '**/*.ts'",
1818
"lint": "eslint --cache --ext ts .",
1919
"prepare": "husky install",
20-
"test:coverage": "pnpm run test --coverage",
21-
"test": "jest"
20+
"test": "vitest run",
21+
"test:coverage": "vitest run --coverage",
22+
"test:ui": "vitest --ui"
2223
},
2324
"lint-staged": {
2425
"*.ts": [
2526
"prettier --write",
2627
"eslint --fix --ext ts"
28+
],
29+
"*.yaml": [
30+
"prettier --write"
31+
],
32+
"*.json": [
33+
"prettier --write"
2734
]
2835
},
2936
"config": {
@@ -36,58 +43,27 @@
3643
"@commitlint/config-conventional"
3744
]
3845
},
39-
"jest": {
40-
"setupFiles": [
41-
"./env-setup.ts"
42-
],
43-
"collectCoverageFrom": [
44-
"packages/*/src/**/*.{ts,tsx}"
45-
],
46-
"coverageReporters": [
47-
"text",
48-
"cobertura"
49-
],
50-
"modulePathIgnorePatterns": [
51-
"<rootDir>/examples/",
52-
"<rootDir>/dist/",
53-
"<rootDir>/packages/clients/src/api/"
54-
],
55-
"reporters": [
56-
"default",
57-
[
58-
"jest-junit",
59-
{
60-
"outputDirectory": ".reports",
61-
"outputName": "tests.xml"
62-
}
63-
]
64-
],
65-
"transformIgnorePatterns": [
66-
"node_modules/(?!(.*(@scaleway)))"
67-
]
68-
},
6946
"devDependencies": {
7047
"@babel/core": "^7.23.9",
7148
"@babel/plugin-transform-runtime": "^7.23.9",
7249
"@babel/preset-env": "^7.23.9",
7350
"@babel/preset-typescript": "^7.23.3",
7451
"@commitlint/cli": "^18.6.0",
7552
"@commitlint/config-conventional": "^18.6.0",
76-
"@jest/globals": "^29.7.0",
7753
"@rollup/plugin-babel": "^6.0.4",
7854
"@rollup/plugin-commonjs": "^25.0.7",
7955
"@rollup/plugin-node-resolve": "^15.2.3",
8056
"@scaleway/eslint-config-react": "^3.17.2",
57+
"@vitest/coverage-istanbul": "1.2.1",
58+
"@vitest/coverage-v8": "1.2.1",
59+
"@vitest/ui": "1.2.1",
8160
"babel-plugin-annotate-pure-calls": "^0.4.0",
8261
"cross-env": "^7.0.3",
8362
"cross-fetch": "^4.0.0",
8463
"cz-conventional-changelog": "^3.3.0",
8564
"eslint": "^8.56.0",
8665
"eslint-plugin-tsdoc": "^0.2.17",
8766
"husky": "^8.0.3",
88-
"jest": "^29.7.0",
89-
"jest-environment-jsdom": "^29.7.0",
90-
"jest-junit": "^16.0.0",
9167
"lerna": "^7.4.2",
9268
"lint-staged": "^15.2.0",
9369
"prettier": "^3.2.4",
@@ -96,7 +72,12 @@
9672
"rollup-plugin-dts": "^6.1.0",
9773
"rollup-plugin-visualizer": "^5.12.0",
9874
"typedoc": "^0.25.7",
99-
"typescript": "^5.3.3"
75+
"typescript": "^5.3.3",
76+
"vite": "5.0.12",
77+
"vitest": "1.2.1"
10078
},
101-
"packageManager": "[email protected]"
79+
"packageManager": "[email protected]",
80+
"dependencies": {
81+
"jsdom": "^24.0.0"
82+
}
10283
}

packages/clients/src/helpers/__tests__/is-browser.browser.ts renamed to packages/clients/src/helpers/__tests__/is-browser.browser.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* @jest-environment jsdom */
2-
import { describe, expect, it } from '@jest/globals'
1+
// @vitest-environment jsdom
2+
import { describe, expect, it } from 'vitest'
33
import { isBrowser } from '../is-browser'
44

55
describe('isBrowser', () => {

packages/clients/src/helpers/__tests__/is-browser.node.ts renamed to packages/clients/src/helpers/__tests__/is-browser.node.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
/* @jest-environment node */
2-
import { describe, expect, it } from '@jest/globals'
1+
// @vitest-environment node
2+
3+
import { describe, expect, it } from 'vitest'
34
import { isBrowser } from '../is-browser'
45

56
describe('isBrowser', () => {

packages/clients/src/helpers/__tests__/json.ts renamed to packages/clients/src/helpers/__tests__/json.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, test } from '@jest/globals'
1+
import { describe, expect, test } from 'vitest'
22
import { isJSON, isJSONObject } from '../json'
33

44
describe('isJSON', () => {

0 commit comments

Comments
 (0)