Skip to content

Commit e450f2b

Browse files
authored
Merge pull request #2124 from aryaemami59/migrate-to-vitest
Migrate from Jest to Vitest
2 parents ff3115c + c29ce2f commit e450f2b

19 files changed

+1524
-5553
lines changed

babel.config.js

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

jest.config.js

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

jest.setupAfter.js

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

package.json

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"lint:fix": "eslint src test --fix",
4545
"prepare": "yarn clean && yarn build",
4646
"pretest": "yarn lint",
47-
"test": "jest",
47+
"test": "vitest --run",
48+
"test:watch": "vitest --watch",
4849
"type-tests": "yarn tsc -p test/typetests/tsconfig.json",
4950
"coverage": "codecov"
5051
},
@@ -82,18 +83,14 @@
8283
"@babel/preset-typescript": "^7.14.5",
8384
"@microsoft/api-extractor": "^7.18.1",
8485
"@reduxjs/toolkit": "^2.0.0-beta.4",
85-
"@testing-library/jest-dom": "^5.11.5",
86-
"@testing-library/jest-native": "^3.4.3",
87-
"@testing-library/react": "13.0.0",
88-
"@testing-library/react-12": "npm:@testing-library/react@^12",
89-
"@testing-library/react-hooks": "^3.4.2",
90-
"@testing-library/react-native": "^7.1.0",
86+
"@testing-library/jest-dom": "^6.3.0",
87+
"@testing-library/react": "^14.1.2",
88+
"@testing-library/react-hooks": "^8.0.1",
89+
"@types/node": "^20.11.6",
9190
"@types/react": "18.2.25",
92-
"@types/react-native": "^0.67.4",
9391
"@typescript-eslint/eslint-plugin": "^6.17.0",
9492
"@typescript-eslint/parser": "^6.17.0",
9593
"babel-eslint": "^10.1.0",
96-
"babel-jest": "^29",
9794
"codecov": "^3.8.0",
9895
"cross-env": "^7.0.2",
9996
"eslint": "^8.56.0",
@@ -102,18 +99,15 @@
10299
"eslint-plugin-prettier": "^5.1.2",
103100
"eslint-plugin-react": "^7.33.2",
104101
"glob": "^7.1.6",
105-
"jest": "^29",
106-
"jest-environment-jsdom": "^29.5.0",
107-
"metro-react-native-babel-preset": "^0.76.6",
102+
"jsdom": "^24.0.0",
108103
"prettier": "^3.1.1",
109104
"react": "18.2.0",
110105
"react-dom": "18.2.0",
111-
"react-native": "^0.71.11",
112106
"react-test-renderer": "18.0.0",
113107
"redux": "^5.0.0",
114108
"rimraf": "^3.0.2",
115-
"ts-jest": "^29",
116109
"tsup": "^7.0.0",
117-
"typescript": "^5.0"
110+
"typescript": "^5.0",
111+
"vitest": "^1.2.1"
118112
}
119113
}

rollup.config.js

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

test/components/Provider.spec.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { createStore } from 'redux'
88
import type { ReactReduxContextValue } from '../../src'
99
import { Provider, ReactReduxContext, connect } from '../../src/index'
1010

11-
import '@testing-library/jest-dom/extend-expect'
1211
import * as ReactDOM from 'react-dom'
1312

1413
const createExampleTextReducer =
@@ -51,7 +50,7 @@ describe('React', () => {
5150
it('should not enforce a single child', () => {
5251
const store = createStore(() => ({}))
5352

54-
const spy = jest.spyOn(console, 'error').mockImplementation(() => {})
53+
const spy = vi.spyOn(console, 'error').mockImplementation(() => {})
5554

5655
expect(() =>
5756
rtl.render(
@@ -79,7 +78,7 @@ describe('React', () => {
7978
it('should add the store to context', () => {
8079
const store = createStore(createExampleTextReducer())
8180

82-
const spy = jest.spyOn(console, 'error').mockImplementation(() => {})
81+
const spy = vi.spyOn(console, 'error').mockImplementation(() => {})
8382
const tester = rtl.render(
8483
<Provider store={store}>
8584
<Child />
@@ -170,7 +169,7 @@ describe('React', () => {
170169
action.type === 'INC' ? state + 1 : state
171170

172171
const innerStore = createStore(reducer)
173-
const innerMapStateToProps = jest.fn<TStateProps, [number]>((state) => ({
172+
const innerMapStateToProps = vi.fn<TStateProps, [number]>((state) => ({
174173
count: state,
175174
}))
176175
class Inner extends Component<TStateProps> {
@@ -315,7 +314,7 @@ describe('React', () => {
315314
if (!React.StrictMode) {
316315
return
317316
}
318-
const spy = jest.spyOn(console, 'error').mockImplementation(() => {})
317+
const spy = vi.spyOn(console, 'error').mockImplementation(() => {})
319318
const store = createStore(() => ({}))
320319

321320
rtl.render(
@@ -334,7 +333,7 @@ describe('React', () => {
334333
const subscribe = store.subscribe
335334

336335
// Keep track of unsubscribe by wrapping subscribe()
337-
const spy = jest.fn(() => ({}))
336+
const spy = vi.fn(() => ({}))
338337
store.subscribe = (listener) => {
339338
const unsubscribe = subscribe(listener)
340339
return () => {

0 commit comments

Comments
 (0)