@tracetest/playwright
v0.2.1
Published
Tracetest x Playwright
Downloads
1,093
Readme
@tracetest/playwright
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, context }, { title }) => {
await tracetest?.capture({title, page, context});
await page.goto('/');
});
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
> [email protected] 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
- For a detailed step-by-step tutorial on how to use this module: visit https://docs.tracetest.io/tools-and-integrations/playwright
- For a blog post written around this integration: visit https://tracetest.io/blog/the-lord-of-playwright-the-two-traces
- If you want to get in touch with the Tracetest team: visit https://dub.sh/tracetest-community