Difference between revisions of "Jest"
From Wasya Wiki
(Created page with " <pre> // const mockPush = jest.fn() // jest.mock('react-router-dom', () => { // const originalModule = jest.requireActual('react-router-dom') // return { // __esModu...") |
|||
Line 15: | Line 15: | ||
</pre> | </pre> | ||
+ | == mock api == | ||
<pre> | <pre> | ||
− | + | jest.mock('$shared/Api') | |
// jest.mock('$shared/Api', () => { | // jest.mock('$shared/Api', () => { | ||
// return { | // return { |
Revision as of 18:54, 18 September 2022
// const mockPush = jest.fn() // jest.mock('react-router-dom', () => { // const originalModule = jest.requireActual('react-router-dom') // return { // __esModule: true, // ...originalModule, // useHistory: () => ({ // push: mockPush, // }), // } // })
mock api
jest.mock('$shared/Api') // jest.mock('$shared/Api', () => { // return { // __esModule: true, // default: () => { // return { // getCity: () => { // return new Promise((resolve, reject) => { // resolve({ // data: { // city: { // newsitems: [{ name: 'report-name-2', item_type: 'Report' }] // } // } // }) // }) // }, // } // }, // } // })