Integrating Playwright Test Results with PractiTest

If you’re using Playwright for test automation, you can seamlessly connect your efforts with PractiTest. You can do it either through the API or by using PractiTest’s FireCracker tool. With FireCracker, you can simply upload Playwright’s XML report, making it easy to keep track of all your test results and manage them efficiently in PractiTest.

Executing a Test Case with Playwright

This is an example code snippet of tests executed in Playwright:

const { test, expect } = require('@playwright/test');




test.beforeEach(async ({ page }) => {
 await page.goto('https://www.practitest.com');
});




test('should navigate to the product page and find header', async ({ page }) => {
 await page.getByRole('link', { name: 'Product', exact: true }).click();
 const hub_heading = page.getByRole('heading', { name: 'Centralized Hub' });
 await expect(hub_heading).toBeVisible();
});


test('should have free trial button', async ({ page }) => {
 const visible = await page.getByRole('link', { name: 'Free Trial' }).first().isVisible();
});

Create an XML Report with Playwright

By default, Playwright generates a JUnit-XML report. Execute the following command to run the tests and generate the JUnit-XML report:

PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --reporter=junit
Example XML Output
<testsuites id="" name="" tests="6" failures="0" skipped="0" errors="0" time="7.246564">
<testsuite name="pt_demo.spec.ts" timestamp="2024-04-15T12:11:47.697Z" hostname="chromium" tests="2" failures="0" skipped="0" time="7.569" errors="0">
<testcase name="should navigate to the product page and find header" classname="pt_demo.spec.ts" time="4.236">
</testcase>
<testcase name="should have free trial button" classname="pt_demo.spec.ts" time="3.333">
</testcase>
</testsuite>
<testsuite name="pt_demo.spec.ts" timestamp="2024-04-15T12:11:47.697Z" hostname="firefox" tests="2" failures="0" skipped="0" time="8.852" errors="0">
<testcase name="should navigate to the product page and find header" classname="pt_demo.spec.ts" time="5.071">
</testcase>
<testcase name="should have free trial button" classname="pt_demo.spec.ts" time="3.781">
</testcase>
</testsuite>
<testsuite name="pt_demo.spec.ts" timestamp="2024-04-15T12:11:47.697Z" hostname="webkit" tests="2" failures="0" skipped="0" time="6.454" errors="0">
<testcase name="should navigate to the product page and find header" classname="pt_demo.spec.ts" time="3.576">
</testcase>
<testcase name="should have free trial button" classname="pt_demo.spec.ts" time="2.878">
</testcase>
</testsuite>
</testsuites>

Uploading Playwright Test Results to PractiTest

After creating the JUnit-XML report with Playwright, you can upload your test results to PractiTest using FireCracker which supports various formats such as Junit, and integrate the results to PractiTest.

To learn how to use FireCracker, please check this help page.

You can also watch the following tutorial video: