This minimal preact
app (created following these instructions) showcases preact-perf-metrics
.
There're two examples, /counters
and /items-list
, and each has an associated perf-test: /counters, /items-list.
To run the performance tests:
- step into this directory (
/example
) - Install dependencies:
npm install
- Run the application:
npm run dev
- In a different terminal (while de application is running), run the tests:
npm run test:perf
It happens in the main file using the setup()
function from @loveholidays/preact-perf-metrics/setup
It happens in the playwright config file when doing
import { expect } from '@playwright/test';
import { extension } from '@loveholidays/preact-perf-metrics';
expect.extend(extension);
Note
This can also be done on the test file itself or in another file (see playwright-custom-matchers docs)
The test files under perf-test folder
Note that for each interaction you want to test you need to call reset()
before (to reset the counters).