@tracetest/playwright
TypeScript icon, indicating that this package has built-in type declarations

0.0.41 • Public • Published

@tracetest/playwright

NPM Published Version

About

This module provides a way to enhance your existing Playwright E2E tests with trace-based testing. It allows you to create, run, and orchestrate Tracetest Tests based on your existing Playwright scripts with minimal configuration and code.

To find a detailed step-by-step tutorial on how to use this module head out to the main integration page in our docs.

Usage

Import and Create the Tracetest Instance

import Tracetest, { Types } from '@tracetest/playwright';

const { TRACETEST_API_TOKEN = '' } = process.env;

let tracetest: Types.TracetestPlaywright | undefined = undefined;

test.beforeAll(async () => {
  tracetest = await Tracetest({ apiToken: TRACETEST_API_TOKEN });
});

Follow the guide in the Tracetest documentation website to generate the TRACETEST_API_TOKEN

Capture the Tracetest Parent for the Current Test

test.beforeEach(async ({ page }, { title }) => {
  await page.goto('/');
  await tracetest?.capture(title, page);
});

Wait for the Trace-Based Tests to Complete

// Optional: You can add this to the code to fail the execution based on the trace-based tests results
test.afterAll(async ({}, testInfo) => {
  testInfo.setTimeout(80000);
  await tracetest?.summary();
});

Output

> pokeshop@1.0.0 pw:run
> playwright test


Running 1 test using 1 worker
[chromium] › home.spec.ts:53:5 › Playwright: imports a pokemon
Test `Playwright: imports a pokemon` started
Find the results at https://app.tracetest.io/organizations/ttorg_ced62e34638d965e/environments/ttenv_b42fa137465c6e04/test/UGxheXdyaWdodDogaW1wb3J0cyBhIHBva2Vtb24=/run/73
Test `Playwright: imports a pokemon` finished

Successful: 1
Failed: 0

[SUCCESSFUL - FINISHED] Playwright: imports a pokemon - https://app.tracetest.io/organizations/ttorg_ced62e34638d965e/environments/ttenv_b42fa137465c6e04/test/UGxheXdyaWdodDogaW1wb3J0cyBhIHBva2Vtb24=/run/73

  1 passed (19.5s)

To open last HTML report run:

  npx playwright show-report

Useful Links

Package Sidebar

Install

npm i @tracetest/playwright

Repository

tracetest.io

Homepage

tracetest.io

Weekly Downloads

855

Version

0.0.41

License

ISC

Unpacked Size

46.5 kB

Total Files

11

Last publish

Collaborators

  • xoscar
  • olensmar