0.1.0 • Published 4 years ago

@web/test-runner-helpers v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Test Runner Helpers

Helpers for running tests with @web/test-runner.

Usage

Install the library:

npm i -D @web/test-runner-helpers

Viewport

You can set the browser viewport using the setViewport function. This affects all tests in the current test file.

import { setViewport } from '@web/test-runner-helpers';

describe('my component', () => {
  it('works on 360x640', async () => {
    await page.setViewport({ height: 640, width: 360 });
    console.log(window.innerHeight); // 640
    console.log(window.innerWidth); // 360
    // test implementation
  });

  it('works on 400x800', async () => {
    await setViewport({ width: 400, height: 800 });
    console.log(window.innerHeight); // 400
    console.log(window.innerWidth); // 800
    // test implementation
  });
});