Created
February 2, 2023 13:23
-
-
Save pytqqq/25b786e88a4f19c4db9ab010e7821fae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {NativeBaseProvider} from 'native-base'; | |
import {measurePerformance} from 'reassure'; | |
import {GameList} from './GameList'; | |
jest.setTimeout(60_000); | |
jest.mock('../hooks', () => ({ | |
useGetGames: () => ({ | |
data: { | |
pages: [ | |
{ | |
results: Array.from({length: 100}, () => ({ | |
id: Math.random() * 10000, | |
name: Math.random().toString(36).substring(7), | |
background_url: `https://i.imgur.com/${Math.random() | |
.toString(36) | |
.substring(2)}.jpg`, | |
})), | |
}, | |
], | |
}, | |
hasNextPage: true, | |
fetchNextPage: jest.fn(), | |
isFetchingNextPage: false, | |
}), | |
})); | |
test('GameList perf test', async () => { | |
const initialWindowMetrics = { | |
frame: { | |
x: 0, | |
y: 0, | |
width: 0, | |
height: 0, | |
}, | |
insets: { | |
top: 0, | |
left: 0, | |
right: 0, | |
bottom: 0, | |
}, | |
}; | |
const createWrapper = () => { | |
return (node: JSX.Element) => ( | |
<NativeBaseProvider initialWindowMetrics={initialWindowMetrics}> | |
{node} | |
</NativeBaseProvider> | |
); | |
}; | |
const wrapper = createWrapper(); | |
await measurePerformance(<GameList />, { | |
wrapper, | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment