@dnvgl/playwright-duration

1.0.3 • Public • Published

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

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:

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();
  });
});

Package Sidebar

Install

npm i @dnvgl/playwright-duration

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

2.84 kB

Total Files

3

Last publish

Collaborators

  • michael.goeke
  • bruno.pbarbosa
  • oystein.bjorke
  • krykar