如何在react测试库中覆盖延迟加载组件。
import React, {lazy} from 'react';
const ownerInfo = lazy(() => import('../abc'))
const compone = () => {
return <Suspense><abc /></Suspense>
}
export default compone
test.spec.js
import React from 'react'
import {render, fireEvent} from '@testing-library/react'
import configureStore from 'redux-mock-store'
...
1条答案
按热度按时间baubqpgj1#
看完视频后,我能够弄清楚如何覆盖懒惰加载。让我们假设你有懒惰加载组件。
LazyLoad.jsx
:LazyComponent.jsx
:LazyLoad.spec.jsx
: