Coder Social home page Coder Social logo

jricerch / playwright-test-coverage Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anishkny/playwright-test-coverage

0.0 0.0 0.0 1.47 MB

Extends Playwright test to measure code coverage

Home Page: https://npmjs.com/playwright-test-coverage

License: MIT License

Shell 26.31% JavaScript 73.69%

playwright-test-coverage's Introduction

Playwright Test Coverage

CI/CD Depfu npm

A Playwright extension that collects code coverage from running end-to-end tests. Assumes that code has been instrumented with babel-plugin-istanbul during the build process.

Prerequisites

  • Playwright test framework
  • babel-plugin-istanbul plugin
  • nyc for running tests
npm i -D @playwright/test babel-plugin-istanbul nyc

Installation

npm i -D playwright-test-coverage

Usage

Write your Playwright tests as usual, except require test and expect from this package as follows:

// tests/foo.spec.js
const { test, expect } = require("playwright-test-coverage");

// Use test and expect as usual
test("basic test", async ({ page }) => {
  await page.goto("https://playwright.dev/");
  const title = page.locator(".navbar__inner .navbar__title");
  await expect(title).toHaveText("Playwright");
});

Then, instrument your front end source code for coverage using the babel-plugin-istanbul plugin.

Finally, run your server via nyc to capture code coverage. For more details see istanbul/nyc.

Options

  • ISTANBUL_TEMP_DIR - Set this environment variable to specify where Istanbul coverage files should be output. Defaults to $CWD/.nyc_output.

Demo

See anishkny/playwright-test-coverage-demo or accompanying blog post.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Acknowledgements

Inspired by mxschmitt/playwright-test-coverage.

License

MIT

playwright-test-coverage's People

Contributors

depfu[bot] avatar anishkny avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.