https://github.com/dnv-opensource/playwright-duration
Override playwright's duration within a test. Better performance accuracy when wanting to measure timing for only part of a test.
https://github.com/dnv-opensource/playwright-duration
Last synced: 2 months ago
JSON representation
Override playwright's duration within a test. Better performance accuracy when wanting to measure timing for only part of a test.
- Host: GitHub
- URL: https://github.com/dnv-opensource/playwright-duration
- Owner: dnv-opensource
- License: mit
- Created: 2024-05-01T17:49:07.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-03T15:47:32.000Z (about 2 years ago)
- Last Synced: 2025-10-05T12:48:32.958Z (9 months ago)
- Language: TypeScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# playwright-duration
Micro lib to allow fine grained control of reported test time on tests.
Useful when measuring performance for single user workflow tests.
# Installation
``` sh
npm install --save-dev @dnvgl/playwright-duration
```
# Usage
given a playwright test, import and wrap the `duration` function around the code under test you'd like to time
Example:
``` ts
import { test, expect } from '@playwright/test';
import { duration } from '@dnvgl/playwright-duration';
test('get started link', async ({ page }, testInfo) => {
//test setup
await page.goto('https://playwright.dev/');
//after main page load, would like to measure the time to load the `Get started` link
await duration(testInfo, async () => {
await page.getByRole('link', { name: 'Get started' }).click();
await expect(page.getByRole('heading', { name: 'Installation' })).toBeVisible();
});
});
```