web-test-runner-screenshot

1.2.0 • Public • Published

Web-test-runner-screenshot

This is a web-test-runner plugin to capture screenshots during regular tests in playwright.

Usage

npm install --save-dev web-test-runner-screenshot

In your web-test-runner file

import { takeScreenshotPlugin } from 'web-test-runner-screenshot/plugin';

export default {
    ...
    plugins: {
        ...
        takeScreenshotPlugin(),
    }
}

In your test file

import { makeScreenshot } from 'web-test-runner-screenshot';

Inside your test

      it('My awesome test', async () => {
        // My webcomponent test
        expect(true).to.be.true;
        await makeScreenshot({ name: 'my_screenshot-filename' });
      });

Or make it automatically to every test in your afterEach, based on the test title

  afterEach(async function () { // Note that you can't use arrow function because you lose the currentTest context
    await makeScreenshot({ name: this.currentTest.title });
  });

Parameters

makeScreenshot accepts a configuration parameter with the following options

Parameter Type Description Default value Mandatory
name string name of the file - yes
browser boolean append the browser context to the file name false no
folder string folder to store the screenshots evidences no

Readme

Keywords

none

Package Sidebar

Install

npm i web-test-runner-screenshot

Weekly Downloads

0

Version

1.2.0

License

ISC

Unpacked Size

3.73 kB

Total Files

4

Last publish

Collaborators

  • vlaraort