Skip to content

Commit

Permalink
Merge pull request #2124 from aryaemami59/migrate-to-vitest
Browse files Browse the repository at this point in the history
Migrate from Jest to Vitest
  • Loading branch information
EskiMojo14 authored Jan 27, 2024
2 parents ff3115c + c29ce2f commit e450f2b
Show file tree
Hide file tree
Showing 19 changed files with 1,524 additions and 5,553 deletions.
32 changes: 0 additions & 32 deletions babel.config.js

This file was deleted.

30 changes: 0 additions & 30 deletions jest.config.js

This file was deleted.

3 changes: 0 additions & 3 deletions jest.setupAfter.js

This file was deleted.

24 changes: 9 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"lint:fix": "eslint src test --fix",
"prepare": "yarn clean && yarn build",
"pretest": "yarn lint",
"test": "jest",
"test": "vitest --run",
"test:watch": "vitest --watch",
"type-tests": "yarn tsc -p test/typetests/tsconfig.json",
"coverage": "codecov"
},
Expand Down Expand Up @@ -82,18 +83,14 @@
"@babel/preset-typescript": "^7.14.5",
"@microsoft/api-extractor": "^7.18.1",
"@reduxjs/toolkit": "^2.0.0-beta.4",
"@testing-library/jest-dom": "^5.11.5",
"@testing-library/jest-native": "^3.4.3",
"@testing-library/react": "13.0.0",
"@testing-library/react-12": "npm:@testing-library/react@^12",
"@testing-library/react-hooks": "^3.4.2",
"@testing-library/react-native": "^7.1.0",
"@testing-library/jest-dom": "^6.3.0",
"@testing-library/react": "^14.1.2",
"@testing-library/react-hooks": "^8.0.1",
"@types/node": "^20.11.6",
"@types/react": "18.2.25",
"@types/react-native": "^0.67.4",
"@typescript-eslint/eslint-plugin": "^6.17.0",
"@typescript-eslint/parser": "^6.17.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^29",
"codecov": "^3.8.0",
"cross-env": "^7.0.2",
"eslint": "^8.56.0",
Expand All @@ -102,18 +99,15 @@
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-react": "^7.33.2",
"glob": "^7.1.6",
"jest": "^29",
"jest-environment-jsdom": "^29.5.0",
"metro-react-native-babel-preset": "^0.76.6",
"jsdom": "^24.0.0",
"prettier": "^3.1.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "^0.71.11",
"react-test-renderer": "18.0.0",
"redux": "^5.0.0",
"rimraf": "^3.0.2",
"ts-jest": "^29",
"tsup": "^7.0.0",
"typescript": "^5.0"
"typescript": "^5.0",
"vitest": "^1.2.1"
}
}
55 changes: 0 additions & 55 deletions rollup.config.js

This file was deleted.

11 changes: 5 additions & 6 deletions test/components/Provider.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { createStore } from 'redux'
import type { ReactReduxContextValue } from '../../src'
import { Provider, ReactReduxContext, connect } from '../../src/index'

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

const createExampleTextReducer =
Expand Down Expand Up @@ -51,7 +50,7 @@ describe('React', () => {
it('should not enforce a single child', () => {
const store = createStore(() => ({}))

const spy = jest.spyOn(console, 'error').mockImplementation(() => {})
const spy = vi.spyOn(console, 'error').mockImplementation(() => {})

expect(() =>
rtl.render(
Expand Down Expand Up @@ -79,7 +78,7 @@ describe('React', () => {
it('should add the store to context', () => {
const store = createStore(createExampleTextReducer())

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

const innerStore = createStore(reducer)
const innerMapStateToProps = jest.fn<TStateProps, [number]>((state) => ({
const innerMapStateToProps = vi.fn<TStateProps, [number]>((state) => ({
count: state,
}))
class Inner extends Component<TStateProps> {
Expand Down Expand Up @@ -315,7 +314,7 @@ describe('React', () => {
if (!React.StrictMode) {
return
}
const spy = jest.spyOn(console, 'error').mockImplementation(() => {})
const spy = vi.spyOn(console, 'error').mockImplementation(() => {})
const store = createStore(() => ({}))

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

// Keep track of unsubscribe by wrapping subscribe()
const spy = jest.fn(() => ({}))
const spy = vi.fn(() => ({}))
store.subscribe = (listener) => {
const unsubscribe = subscribe(listener)
return () => {
Expand Down
Loading

0 comments on commit e450f2b

Please sign in to comment.