diff --git a/babel.config.js b/babel.config.js deleted file mode 100644 index 3341ee5ef..000000000 --- a/babel.config.js +++ /dev/null @@ -1,32 +0,0 @@ -const { NODE_ENV, BABEL_ENV } = process.env -const cjs = NODE_ENV === 'test' || BABEL_ENV === 'commonjs' - -module.exports = { - presets: [ - [ - '@babel/preset-env', - { - targets: { - esmodules: true, - }, - // Use the equivalent of `babel-preset-modules` - bugfixes: true, - modules: false, - loose: true, - }, - ], - '@babel/preset-typescript', - 'module:metro-react-native-babel-preset', - ], - plugins: [ - ['@babel/proposal-decorators', { legacy: true }], - '@babel/transform-react-jsx', - ['@babel/plugin-proposal-class-properties', { loose: true }], - ['@babel/plugin-proposal-private-methods', { loose: true }], - ['@babel/plugin-proposal-private-property-in-object', { loose: true }], - cjs && ['@babel/transform-modules-commonjs'], - ].filter(Boolean), - assumptions: { - enumerableModuleMeta: true, - }, -} diff --git a/jest.config.js b/jest.config.js deleted file mode 100644 index edc80cbea..000000000 --- a/jest.config.js +++ /dev/null @@ -1,30 +0,0 @@ -process.env.TS_JEST_DISABLE_VER_CHECKER = true - -const NORMAL_TEST_FOLDERS = ['components', 'hooks', 'integration', 'utils'] - -const tsTestFolderPath = (folderName) => - `/test/${folderName}/**/*.{ts,tsx}` - -const tsStandardConfig = { - displayName: 'ReactDOM 18', - preset: 'ts-jest', - testMatch: NORMAL_TEST_FOLDERS.map(tsTestFolderPath), - testEnvironment: 'jsdom', - setupFilesAfterEnv: ['/jest.setupAfter.js'], -} - -const rnConfig = { - displayName: 'React Native', - testMatch: [tsTestFolderPath('react-native')], - preset: 'react-native', - transform: { - '^.+\\.(js|jsx|ts|tsx)$': [ - 'babel-jest', - { configFile: './babel.config.js' }, // <- cannot use rootDir here - ], - }, -} - -module.exports = { - projects: [tsStandardConfig, rnConfig], -} diff --git a/jest.setupAfter.js b/jest.setupAfter.js deleted file mode 100644 index 4f72f201f..000000000 --- a/jest.setupAfter.js +++ /dev/null @@ -1,3 +0,0 @@ -const { TextEncoder, TextDecoder } = require('util') -global.TextEncoder = TextEncoder -global.TextDecoder = TextDecoder diff --git a/package.json b/package.json index 685a339d4..900bbf671 100644 --- a/package.json +++ b/package.json @@ -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" }, @@ -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", @@ -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" } } diff --git a/rollup.config.js b/rollup.config.js deleted file mode 100644 index 2f8d004ff..000000000 --- a/rollup.config.js +++ /dev/null @@ -1,55 +0,0 @@ -import nodeResolve from '@rollup/plugin-node-resolve' -import babel from '@rollup/plugin-babel' -import replace from '@rollup/plugin-replace' -import commonjs from '@rollup/plugin-commonjs' -import { terser } from 'rollup-plugin-terser' -import pkg from './package.json' - -const env = process.env.NODE_ENV - -const extensions = ['.js', '.ts', '.tsx', '.json'] - -const config = { - input: 'src/index.ts', - external: Object.keys(pkg.peerDependencies || {}).concat('react-dom'), - output: { - format: 'umd', - name: 'ReactRedux', - globals: { - react: 'React', - redux: 'Redux', - 'react-dom': 'ReactDOM', - }, - }, - plugins: [ - nodeResolve({ - extensions, - }), - babel({ - include: 'src/**/*', - exclude: '**/node_modules/**', - babelHelpers: 'runtime', - extensions, - }), - replace({ - 'process.env.NODE_ENV': JSON.stringify(env), - preventAssignment: true, - }), - commonjs(), - ], -} - -if (env === 'production') { - config.plugins.push( - terser({ - compress: { - pure_getters: true, - unsafe: true, - unsafe_comps: true, - warnings: false, - }, - }) - ) -} - -export default config diff --git a/test/components/Provider.spec.tsx b/test/components/Provider.spec.tsx index 0dce37f6e..05b7704e9 100644 --- a/test/components/Provider.spec.tsx +++ b/test/components/Provider.spec.tsx @@ -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 = @@ -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( @@ -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( @@ -170,7 +169,7 @@ describe('React', () => { action.type === 'INC' ? state + 1 : state const innerStore = createStore(reducer) - const innerMapStateToProps = jest.fn((state) => ({ + const innerMapStateToProps = vi.fn((state) => ({ count: state, })) class Inner extends Component { @@ -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( @@ -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 () => { diff --git a/test/components/connect.spec.tsx b/test/components/connect.spec.tsx index 66c32c8f0..f7f984f87 100644 --- a/test/components/connect.spec.tsx +++ b/test/components/connect.spec.tsx @@ -1,16 +1,15 @@ /*eslint-disable react/prop-types*/ -import '@testing-library/jest-dom/extend-expect' import * as rtl from '@testing-library/react' import type { Dispatch, ElementType, MouseEvent, ReactNode } from 'react' import React, { Component } from 'react' import type { - Action, - AnyAction, - MiddlewareAPI, - Dispatch as ReduxDispatch, - Store, - UnknownAction, + Action, + AnyAction, + MiddlewareAPI, + Dispatch as ReduxDispatch, + Store, + UnknownAction, } from 'redux' import { applyMiddleware, createStore } from 'redux' import type { ReactReduxContextValue } from '../../src/index' @@ -199,7 +198,7 @@ describe('React', () => { string: state, }))(Container) - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) const tester = rtl.render( @@ -243,7 +242,7 @@ describe('React', () => { string: state, }))(Container) - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) const tester = rtl.render( @@ -261,7 +260,7 @@ describe('React', () => { }) it('should throw an error if the store is not in the props or context', () => { - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) class Container extends Component { render() { @@ -643,7 +642,7 @@ describe('React', () => { } class AwesomeMap {} - let spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + let spy = vi.spyOn(console, 'error').mockImplementation(() => {}) rtl.render( {makeContainer( @@ -660,7 +659,7 @@ describe('React', () => { spy.mockRestore() rtl.cleanup() - spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + spy = vi.spyOn(console, 'error').mockImplementation(() => {}) rtl.render( {makeContainer( @@ -677,7 +676,7 @@ describe('React', () => { spy.mockRestore() rtl.cleanup() - spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + spy = vi.spyOn(console, 'error').mockImplementation(() => {}) rtl.render( {makeContainer( @@ -694,7 +693,7 @@ describe('React', () => { spy.mockRestore() rtl.cleanup() - spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + spy = vi.spyOn(console, 'error').mockImplementation(() => {}) rtl.render( {makeContainer( @@ -711,7 +710,7 @@ describe('React', () => { spy.mockRestore() rtl.cleanup() - spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + spy = vi.spyOn(console, 'error').mockImplementation(() => {}) rtl.render( {makeContainer( @@ -728,7 +727,7 @@ describe('React', () => { spy.mockRestore() rtl.cleanup() - spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + spy = vi.spyOn(console, 'error').mockImplementation(() => {}) rtl.render( {makeContainer( @@ -745,7 +744,7 @@ describe('React', () => { spy.mockRestore() rtl.cleanup() - spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + spy = vi.spyOn(console, 'error').mockImplementation(() => {}) rtl.render( {makeContainer( @@ -762,7 +761,7 @@ describe('React', () => { spy.mockRestore() rtl.cleanup() - spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + spy = vi.spyOn(console, 'error').mockImplementation(() => {}) rtl.render( {makeContainer( @@ -779,7 +778,7 @@ describe('React', () => { spy.mockRestore() rtl.cleanup() - spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + spy = vi.spyOn(console, 'error').mockImplementation(() => {}) rtl.render( {makeContainer( @@ -1297,7 +1296,7 @@ describe('React', () => { , ) - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) rtl.act(() => { linkA.current!.click() linkB.current!.click() @@ -1345,7 +1344,7 @@ describe('React', () => { ) expect(mapStateToPropsCalls).toBe(1) - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) unmount() expect(spy).toHaveBeenCalledTimes(0) expect(mapStateToPropsCalls).toBe(1) @@ -1380,7 +1379,7 @@ describe('React', () => { }) expect(mapStateToPropsCalls).toBe(1) - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) rtl.act(() => { store.dispatch({ type: 'APPEND', body: 'a' }) }) @@ -1456,7 +1455,7 @@ describe('React', () => { describe('Performance optimizations and bail-outs', () => { it('should shallowly compare the selected state to prevent unnecessary updates', () => { const store: Store = createStore(stringBuilder) - const spy = jest.fn(() => ({})) + const spy = vi.fn(() => ({})) interface RenderProps { string: string } @@ -1511,7 +1510,7 @@ describe('React', () => { it('should shallowly compare the merged state to prevent unnecessary updates', () => { const store: Store = createStore(stringBuilder) - const spy = jest.fn(() => ({})) + const spy = vi.fn(() => ({})) interface PassObjType { val?: string prop?: string @@ -2023,7 +2022,7 @@ describe('React', () => { } } - const mapStateToProps = jest.fn((state) => ({ count: state })) + const mapStateToProps = vi.fn((state) => ({ count: state })) interface ChildrenTStateProps { count: RootStateType @@ -2089,7 +2088,7 @@ describe('React', () => { } type ChildNoDisPatch = {} type ChildOwnProps = {} - const mapStateToProps = jest.fn((state) => ({ count: state })) + const mapStateToProps = vi.fn((state) => ({ count: state })) class Child extends Component { render() { return
{this.props.count}
@@ -2284,9 +2283,9 @@ describe('React', () => { } type ActionType = UnknownAction type NoDispatchType = {} - const c3Spy = jest.fn() - const c2Spy = jest.fn() - const c1Spy = jest.fn() + const c3Spy = vi.fn() + const c2Spy = vi.fn() + const c1Spy = vi.fn() type Comp3TStatePropsType = Store1State1Type type Comp3NoDispatchType = NoDispatchType @@ -2442,7 +2441,7 @@ describe('React', () => { }, )(A) - const mapStateToPropsB = jest.fn((state) => ({ count: state })) + const mapStateToPropsB = vi.fn((state) => ({ count: state })) class B extends Component { render() { return @@ -2452,7 +2451,7 @@ describe('React', () => { context: customContext, })(B) - const mapStateToPropsC = jest.fn((state) => ({ count: state })) + const mapStateToPropsC = vi.fn((state) => ({ count: state })) class C extends Component { render() { return @@ -2467,7 +2466,7 @@ describe('React', () => { } type DNoDispatchType = {} type DOwnPropsType = {} - const mapStateToPropsD = jest.fn((state) => ({ count: state })) + const mapStateToPropsD = vi.fn((state) => ({ count: state })) class D extends Component { render() { return
{this.props.count}
@@ -2812,7 +2811,7 @@ describe('React', () => { describe('Error handling for invalid arguments', () => { function renderWithBadConnect(Component: ElementType) { const store = createStore(() => ({})) - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) try { rtl.render( @@ -2885,7 +2884,7 @@ describe('React', () => { if (!React.StrictMode) { return } - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) const store: Store = createStore(stringBuilder) class Container extends Component { @@ -2917,7 +2916,7 @@ describe('React', () => { }) it('should warn one-time-only that `pure` options has been removed', () => { - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) const store: Store = createStore(stringBuilder) class ContainerA extends Component { diff --git a/test/components/hooks.spec.tsx b/test/components/hooks.spec.tsx index 92b1654eb..a38daaa4c 100644 --- a/test/components/hooks.spec.tsx +++ b/test/components/hooks.spec.tsx @@ -1,11 +1,10 @@ /*eslint-disable react/prop-types*/ +import * as rtl from '@testing-library/react' import React from 'react' +import type { AnyAction } from 'redux' import { createStore } from 'redux' import { Provider as ProviderMock, connect } from '../../src/index' -import * as rtl from '@testing-library/react' -import '@testing-library/jest-dom/extend-expect' -import type { AnyAction } from 'redux' const IS_REACT_18 = React.version.startsWith('18') @@ -42,8 +41,8 @@ describe('React', () => { }, ) - const mapStateSpy1 = jest.fn() - const renderSpy1 = jest.fn() + const mapStateSpy1 = vi.fn() + const renderSpy1 = vi.fn() let component1StateList: number[] @@ -76,8 +75,8 @@ describe('React', () => { const Component1 = component1Decorator(component1) - const mapStateSpy2 = jest.fn() - const renderSpy2 = jest.fn() + const mapStateSpy2 = vi.fn() + const renderSpy2 = vi.fn() interface Component2Tstate { mappedProp: string[] diff --git a/test/hooks/useReduxContext.spec.tsx b/test/hooks/useReduxContext.spec.tsx index 5d69d8f61..6486bc96b 100644 --- a/test/hooks/useReduxContext.spec.tsx +++ b/test/hooks/useReduxContext.spec.tsx @@ -2,15 +2,15 @@ import { renderHook } from '@testing-library/react-hooks' import { createContext } from 'react' import type { ReactReduxContextValue } from '../../src/components/Context' import { - createReduxContextHook, - useReduxContext, + createReduxContextHook, + useReduxContext, } from '../../src/hooks/useReduxContext' describe('React', () => { describe('hooks', () => { describe('useReduxContext', () => { it('throws if component is not wrapped in provider', () => { - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) const { result } = renderHook(() => useReduxContext()) @@ -25,7 +25,7 @@ describe('React', () => { it('throws if component is not wrapped in provider', () => { const customContext = createContext(null) const useCustomReduxContext = createReduxContextHook(customContext) - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) const { result } = renderHook(() => useCustomReduxContext()) diff --git a/test/hooks/useSelector.spec.tsx b/test/hooks/useSelector.spec.tsx index 14810838a..70124ef5d 100644 --- a/test/hooks/useSelector.spec.tsx +++ b/test/hooks/useSelector.spec.tsx @@ -3,31 +3,31 @@ import * as rtl from '@testing-library/react' import type { DispatchWithoutAction, FunctionComponent, ReactNode } from 'react' import React, { - Suspense, - useCallback, - useContext, - useEffect, - useLayoutEffect, - useReducer, - useState, + Suspense, + useCallback, + useContext, + useEffect, + useLayoutEffect, + useReducer, + useState, } from 'react' import type { Action, AnyAction, Store } from 'redux' import { createStore } from 'redux' import type { UseSelectorOptions } from '../../src/hooks/useSelector' import type { - ProviderProps, - ReactReduxContextValue, - Subscription, - TypedUseSelectorHook, + ProviderProps, + ReactReduxContextValue, + Subscription, + TypedUseSelectorHook, } from '../../src/index' import { - Provider, - ReactReduxContext, - connect, - createSelectorHook, - shallowEqual, - useDispatch, - useSelector, + Provider, + ReactReduxContext, + connect, + createSelectorHook, + shallowEqual, + useDispatch, + useSelector, } from '../../src/index' // disable checks by default @@ -91,7 +91,7 @@ describe('React', () => { }) it('selects the state and renders the component when the store updates', () => { - const selector = jest.fn((s: NormalStateType) => s.count) + const selector = vi.fn((s: NormalStateType) => s.count) let result: number | undefined const Comp = () => { const count = useNormalSelector(selector) @@ -370,7 +370,7 @@ describe('React', () => { count: count + 1, })) - const selector = jest.fn((s: StateType) => { + const selector = vi.fn((s: StateType) => { return s.count }) const renderedItems: number[] = [] @@ -406,7 +406,7 @@ describe('React', () => { count: count + 1, })) - const selector = jest.fn((s: StateType) => { + const selector = vi.fn((s: StateType) => { return s.count }) const renderedItems: number[] = [] @@ -486,7 +486,7 @@ describe('React', () => { parentCount: number } it('ignores transient errors in selector (e.g. due to stale props)', () => { - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) const Parent = () => { const count = useNormalSelector((s) => s.count) @@ -517,7 +517,7 @@ describe('React', () => { }) it('Passes through errors thrown while rendering', () => { - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) const Comp = () => { const result = useSelector((count: number) => { @@ -554,7 +554,7 @@ describe('React', () => { }) it('re-throws errors from the selector that only occur during rendering', () => { - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) const Parent = () => { const count = useNormalSelector((s) => s.count) @@ -589,7 +589,7 @@ describe('React', () => { }) it.skip('allows dealing with stale props by putting a specific connected component above the hooks component', () => { - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) const Parent = () => { const count = useNormalSelector((s) => s.count) @@ -871,7 +871,7 @@ describe('React', () => { }) describe('Development mode checks', () => { - const consoleSpy = jest + const consoleSpy = vi .spyOn(console, 'warn') .mockImplementation(() => {}) afterEach(() => { @@ -892,7 +892,7 @@ describe('React', () => { return null } describe('selector result stability check', () => { - const selector = jest.fn((state: NormalStateType) => state.count) + const selector = vi.fn((state: NormalStateType) => state.count) afterEach(() => { selector.mockClear() @@ -911,7 +911,7 @@ describe('React', () => { rtl.cleanup() - const unstableSelector = jest.fn(() => Math.random()) + const unstableSelector = vi.fn(() => Math.random()) rtl.render( @@ -936,7 +936,7 @@ describe('React', () => { ) }) it('uses provided equalityFn', () => { - const unstableSelector = jest.fn((state: NormalStateType) => ({ + const unstableSelector = vi.fn((state: NormalStateType) => ({ count: state.count, })) diff --git a/test/integration/dynamic-reducers.spec.tsx b/test/integration/dynamic-reducers.spec.tsx index beb47b84e..d199c9748 100644 --- a/test/integration/dynamic-reducers.spec.tsx +++ b/test/integration/dynamic-reducers.spec.tsx @@ -1,13 +1,13 @@ /*eslint-disable react/prop-types*/ +import * as rtl from '@testing-library/react' +import type { ReactNode } from 'react' import React from 'react' import ReactDOMServer from 'react-dom/server' -import { createStore, combineReducers } from 'redux' -import { connect, Provider, ReactReduxContext } from '../../src/index' -import * as rtl from '@testing-library/react' import type { Store } from 'redux' -import type { ReactNode } from 'react' +import { combineReducers, createStore } from 'redux' import type { ReactReduxContextValue } from '../../src/index' +import { Provider, ReactReduxContext, connect } from '../../src/index' describe('React', () => { /* @@ -180,7 +180,7 @@ describe('React', () => { // This generates errors for using useLayoutEffect in v7 // We hide that error by disabling console.error here - jest.spyOn(console, 'error') + vi.spyOn(console, 'error') // eslint-disable-next-line no-console // @ts-ignore console.error.mockImplementation(() => {}) diff --git a/test/integration/server-rendering.spec.tsx b/test/integration/server-rendering.spec.tsx index 9188e45a2..9c1e4ccb9 100644 --- a/test/integration/server-rendering.spec.tsx +++ b/test/integration/server-rendering.spec.tsx @@ -97,7 +97,7 @@ describe('React', () => { it('should run in an SSR environment without logging warnings about useLayoutEffect', () => { const store: Store = createStore(greetingReducer) - const spy = jest.spyOn(console, 'error').mockImplementation(() => {}) + const spy = vi.spyOn(console, 'error').mockImplementation(() => {}) renderToString( diff --git a/test/integration/ssr.spec.tsx b/test/integration/ssr.spec.tsx index a78958b41..96f638f9a 100644 --- a/test/integration/ssr.spec.tsx +++ b/test/integration/ssr.spec.tsx @@ -116,10 +116,10 @@ describe('New v8 serverState behavior', () => { return } - const consoleError = jest.spyOn(console, 'error').mockImplementation(() => {}) + const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {}) afterEach(() => { - jest.clearAllMocks() + vi.clearAllMocks() }) it('Handles hydration correctly', async () => { @@ -164,7 +164,7 @@ describe('New v8 serverState behavior', () => { true, ) - jest.resetAllMocks() + vi.resetAllMocks() expect(consoleError.mock.calls.length).toBe(0) diff --git a/test/react-native/batch-integration.tsx b/test/react-native/batch-integration.tsx deleted file mode 100644 index 21315151e..000000000 --- a/test/react-native/batch-integration.tsx +++ /dev/null @@ -1,606 +0,0 @@ -import '@testing-library/jest-native/extend-expect' -import * as rtl from '@testing-library/react-native' -import React, { Component, useLayoutEffect } from 'react' -import { Button, Text, View, unstable_batchedUpdates } from 'react-native' -import { applyMiddleware, createStore } from 'redux' -import { - Provider as ProviderMock, - batch, - connect, - useDispatch, - useSelector, -} from '../../src/index' -import { useIsomorphicLayoutEffect } from '../../src/utils/useIsomorphicLayoutEffect' - -import type { MiddlewareAPI, Dispatch as ReduxDispatch } from 'redux' - -describe('React Native', () => { - const propMapper = (prop: any) => { - switch (typeof prop) { - case 'object': - case 'boolean': - return JSON.stringify(prop) - case 'function': - return '[function ' + prop.name + ']' - default: - return prop - } - } - - interface PassthroughPropsType { - [x: string]: any - } - class Passthrough extends Component { - render() { - return ( - - {Object.keys(this.props).map((prop) => ( - - {propMapper(this.props[prop])} - - ))} - - ) - } - } - interface ActionType { - type: string - body?: string - } - function stringBuilder(prev = '', action: ActionType) { - return action.type === 'APPEND' ? prev + action.body : prev - } - - afterEach(() => rtl.cleanup()) - - describe('useIsomorphicLayoutEffect', () => { - it('useIsomorphicLayoutEffect should be useLayoutEffect', () => { - expect(useIsomorphicLayoutEffect).toBe(useLayoutEffect) - }) - }) - - describe('Subscription and update timing correctness', () => { - it('should pass state consistently to mapState', () => { - type RootStateType = string - type NoDispatch = {} - - const store = createStore(stringBuilder) - - rtl.act(() => { - store.dispatch({ type: 'APPEND', body: 'a' }) - }) - - let childMapStateInvokes = 0 - interface ContainerTStatePropsType { - state: RootStateType - } - type ContainerOwnOwnPropsType = {} - class Container extends Component { - emitChange() { - store.dispatch({ type: 'APPEND', body: 'b' }) - } - - render() { - return ( - -