Skip to content

Commit 26ff8c8

Browse files
authored
Merge pull request #3102 from reduxjs/feature/2.0-esm-vitest-migration
2 parents aca78ec + 4372061 commit 26ff8c8

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

+2236
-1061
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
- name: Install build artifact
8383
run: yarn workspace @reduxjs/toolkit add $(pwd)/package.tgz
8484

85-
- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./jest.config.js ./src/tests/*.* ./src/query/tests/*.*
85+
- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./vitest.config.ts ./src/tests/*.* ./src/query/tests/*.*
8686

8787
- name: Run tests, against dist
8888
run: yarn test
@@ -121,7 +121,7 @@ jobs:
121121
- name: Install build artifact
122122
run: yarn add ./package.tgz
123123

124-
- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./jest.config.js ./src/tests/*.* ./src/query/tests/*.*
124+
- run: sed -i -e /@remap-prod-remove-line/d ./tsconfig.base.json ./vitest.config.ts ./src/tests/*.* ./src/query/tests/*.*
125125

126126
- name: Test types
127127
run: |
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
diff --git a/src/index.js b/src/index.js
2+
index 90ff7fa3d7d4fa62dbbf638958ae4e28abd089a8..28434687b5163b7472e86bdb11bed69e0868e660 100644
3+
--- a/src/index.js
4+
+++ b/src/index.js
5+
@@ -1,4 +1,4 @@
6+
-import { mockConsole, createConsole } from './pure';
7+
+import { mockConsole, createConsole } from './pure.js';
8+
9+
// Keep an instance of the original console and export it
10+
const originalConsole = global.console;
11+
diff --git a/src/pure.js b/src/pure.js
12+
index b00ea2abbaea833e336676aa46e7ced2d59d6d88..42b83ed83fa16cf2234571500fe09868debd9f01 100644
13+
--- a/src/pure.js
14+
+++ b/src/pure.js
15+
@@ -228,10 +228,11 @@ export function restore() {
16+
global.console = global.originalConsole;
17+
}
18+
19+
+/*
20+
if (typeof expect === 'function' && typeof expect.extend === 'function') {
21+
expect.extend({
22+
toMatchInlineSnapshot(received, ...args) {
23+
- /* ------- Workaround for custom inline snapshot matchers ------- */
24+
+ // Workaround for custom inline snapshot matchers
25+
const error = new Error();
26+
const stacks = error.stack.split('\n');
27+
28+
@@ -245,7 +246,6 @@ if (typeof expect === 'function' && typeof expect.extend === 'function') {
29+
error.stack = stacks.join('\n');
30+
31+
const context = Object.assign(this, { error });
32+
- /* -------------------------------------------------------------- */
33+
34+
const testingConsoleInstance =
35+
(received && received.testingConsole) || received;
36+
@@ -270,3 +270,4 @@ if (typeof expect === 'function' && typeof expect.extend === 'function') {
37+
},
38+
});
39+
}
40+
+*/
41+
\ No newline at end of file

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
"@babel/helper-compilation-targets": "7.19.3",
4444
"@babel/traverse": "7.19.3",
4545
"@babel/types": "7.19.3",
46-
"console-testing-library": "patch:console-testing-library@npm:0.3.1#.yarn/patches/console-testing-library__npm_0.3.1.patch",
4746
"esbuild": "0.17.0",
47+
"jest-snapshot": "29.3.1",
4848
"msw": "patch:msw@npm:0.40.2#.yarn/patches/msw-npm-0.40.2-2107d48752",
4949
"jscodeshift": "0.13.1",
5050
"react-redux": "npm:8.0.2",
@@ -63,7 +63,8 @@
6363
"docs/react-dom": "npm:17.0.2",
6464
"docs/@types/react-dom": "npm:17.0.11",
6565
"docs/@types/react": "npm:17.0.11",
66-
"type-fest": "2.19.0"
66+
"type-fest": "2.19.0",
67+
"console-testing-library@0.6.1": "patch:console-testing-library@npm%3A0.6.1#./.yarn/patches/console-testing-library-npm-0.6.1-4d9957d402.patch"
6768
},
6869
"scripts": {
6970
"build": "yarn build:packages",

packages/rtk-query-codegen-openapi/jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
const { resolve } = require('path');
22

3-
const tsConfigPath = resolve('./test/tsconfig');
3+
const tsConfigPath = resolve('./test/tsconfig.json');
44

55
/** @typedef {import('ts-jest/dist/types')} */
66
/** @type {import('@jest/types').Config.InitialOptions} */
77
const config = {
88
rootDir: './test',
99
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
10+
preset: 'ts-jest',
1011
globals: {
1112
'ts-jest': {
1213
tsconfig: tsConfigPath,

packages/rtk-query-codegen-openapi/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@
4646
"esbuild": "~0.17",
4747
"esbuild-runner": "^2.2.1",
4848
"husky": "^4.3.6",
49-
"jest": "^27",
49+
"jest": "^29",
5050
"msw": "^0.40.2",
5151
"openapi-types": "^9.1.0",
5252
"pretty-quick": "^3.1.0",
53-
"ts-jest": "^27",
53+
"ts-jest": "^29",
5454
"ts-node": "^10.4.0",
5555
"yalc": "^1.0.0-pre.47"
5656
},

packages/rtk-query-codegen-openapi/test/cli.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Done
7070

7171
expect(fromTs).toEqual(fromJs);
7272
expect(fromJson).toEqual(fromJs);
73-
}, 25000);
73+
}, 120000);
7474

7575
test('missing parameters doesnt fail', async () => {
7676
const out = await cli([`./config.invalid-example.json`], __dirname);

packages/rtk-query-codegen-openapi/test/jest.setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-ignore
12
global.fetch = require('node-fetch');
23
const { format } = require('prettier');
34
const { server } = require('./mocks/server');

packages/rtk-query-codegen-openapi/test/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"compilerOptions": {
3+
"lib": ["es2019"],
34
"paths": {
45
"@/*": ["./test/fixtures/*"],
56
"@rtk-query/codegen-openapi": ["./src"]

packages/toolkit/jest.config.js

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

packages/toolkit/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"@typescript-eslint/eslint-plugin": "^4.22.0",
6262
"@typescript-eslint/parser": "^4.22.0",
6363
"axios": "^0.19.2",
64-
"console-testing-library": "^0.3.1",
64+
"console-testing-library": "0.6.1",
6565
"convert-source-map": "^1.7.0",
6666
"esbuild": "~0.17",
6767
"eslint": "^7.25.0",
@@ -75,7 +75,7 @@
7575
"eslint-plugin-react-hooks": "^4.2.0",
7676
"fs-extra": "^9.1.0",
7777
"invariant": "^2.2.4",
78-
"jest": "^27",
78+
"jsdom": "^21.0.0",
7979
"json-stringify-safe": "^5.0.1",
8080
"magic-string": "^0.25.7",
8181
"merge-source-map": "^1.1.0",
@@ -89,10 +89,10 @@
8989
"size-limit": "^4.11.0",
9090
"source-map": "^0.7.3",
9191
"terser": "^5.6.1",
92-
"ts-jest": "^27",
9392
"tslib": "^1.10.0",
9493
"tsx": "^3.12.2",
9594
"typescript": "~4.9",
95+
"vitest": "^0.27.2",
9696
"yargs": "^15.3.1"
9797
},
9898
"scripts": {
@@ -104,7 +104,7 @@
104104
"format": "prettier --write \"(src|examples)/**/*.{ts,tsx}\" \"**/*.md\"",
105105
"format:check": "prettier --list-different \"(src|examples)/**/*.{ts,tsx}\" \"docs/*/**.md\"",
106106
"lint": "eslint src examples",
107-
"test": "jest --runInBand",
107+
"test": "vitest",
108108
"type-tests": "yarn tsc -p src/tests/tsconfig.typetests.json && yarn tsc -p src/query/tests/tsconfig.typetests.json",
109109
"prepack": "npm run build-prepare"
110110
},

0 commit comments

Comments
 (0)