You can use test matchers for react-performance-testing
npm install jest-performance-testing!npm

!GitHub Workflow Status
!GitHub Workflow Status

You can get benefit by using this lib with react-performance-testing. This lib is created to improve DX for react-performance-test users. You can write test quickly and easy.
- Installation
- API
- toBeMounted
- toBeMountedWithin
- toBeUpdatedWithin
- toBeRenderedTimes
- LICENSE
npm:
``sh`
npm install --save-dev jest-performance-testing
yarn:
`sh`
yarn add --dev jest-performance-testing
Note: If you are using TypeScript, we are recommending to import this lib in local file like .test.ts | .spec.ts. This is because, we have expanded jest types, so global types are not recognized by some editors if you import this lib in setup file. If you want to import this lib in setup file, please see here testing-library/jest-dom#123 (comment).
toBeMounted()
This matcher is to check if component is mounted.
`js`
expect(renderCount.current.Component).toBeMounted();
You can use renderTime as bellow.
`js`
expect(renderTime.current.Component).toBeMounted();
toBeMountedWithin(mountedTime: number)
This matcher is to check if mounted time is less than expected time.
`js`
expect(renderTime.current.Component).toBeMountedWithin(16); // ms
toBeUpdatedWithin(updatedTime: number[])
This matcher is to check if some updated time are less than expected time.
`js`
expect(renderTime.current.Component).toBeUpdatedWithin([
10, // first render
15, // second render
20, // third render
]);
If you have same render time, you can write as bellow.
`js`
// All items are 16ms
expect(renderTime.current.Component).toBeUpdatedWithin(16);
toBeRenderedTimes(renderedTimes: number)
This matcher is to check if number of renders are equality.
`js``
expect(renderCount.current.Component).toBeRenderedTimes(1);