Skip to content

Latest commit

 

History

History
50 lines (35 loc) · 1.36 KB

README.md

File metadata and controls

50 lines (35 loc) · 1.36 KB

Playwright Commands for Web Test Runner

This contains custom commands you can register with Web Test Runner (WTR) for interacting with Playwright's page object models. This assumes you are using @web/test-runner-playwright for launching your browser via Playwright and running your tests within the page it creates.

Installation

npm install --save-dev wtr-playwright-commands

Command Usages

Each command can be registered separately with WTR. Details on each supported command are given below.

waitForNetworkIdle

Use this to have a test wait for Playwright to receive its network idle load status before resuming.

Configuration

import { waitForNetworkIdlePlugin } from 'wtr-playwright-commands/plugin.js';

export default {
  plugins: [waitForNetworkIdlePlugin()],
  // ... rest of config ...
}

Usage

import { fixture, html } from '@open-wc/testing';
import { waitForNetworkIdle } from 'wtr-playwright-commands';

import '../src/my-element.js';

describe('MyElement', () => {
  it('can wait for network idle', async () => {
    const el = await fixture(html`<my-element></my-element>`);
    await waitForNetworkIdle();

    // ... do assertions that require network activity to complete ...
  });
});