Playwright test reporting

Playwright (Python)

Playwright recommends using the official Playwright pytest plugin to write end-to-end tests in Python. If that is how you have setup your Playwright tests then integrating Tesults is quick and easy. Utilize the Tesults pytest plugin. Follow the instructions outlined in the documentation and then when you run your Playwright tests using the pytest command supply the tesults target value. Test results data will then be uploaded to Tesults.

pytest --tesults-target token

Replace token with your Tesults target token. If you encounter any issues or are using a different method of running Playwright tests with Python please contact help@tesults.com for assistance.


Playwright (Java)

Playwright documentation explains how to use the JUnit test runner to run Playwright tests in Java. If that is how you have setup your Playwright tests then integrating Tesults is quick and easy. Utilize the Tesults JUnit 5 plugin. Follow the instructions outlined in the documentation and then run your Playwright tests as usual. Test results data will then be uploaded to Tesults.

If you encounter any issues or are using a different method of running Playwright tests with Python please contact help@tesults.com for assistance.


Playwright (.NET)

Playwright states that Playwright for .NET 'works best with the built-in .NET test runner, and using NUnit as the test framework' in their documentation. If that is how you have setup your Playwright tests then integrating Tesults is quick and easy. Utilize the Tesults NUnit 3 extension. Follow the instructions outlined in the documentation (for .NET/.NET Core) and then when you run your Playwright tests using the dotnet test command supply the runsettings file containing your Tesults target token. Test results data will then be uploaded to Tesults.

dotnet test -s test.runsettings

If you encounter any issues or are using a different method of running Playwright tests with Python please contact help@tesults.com for assistance.



Playwright (Node.js)

If you are not using the Playwright test framework but are using JavaScript/Node.js view the Node.js docs instead for integrating with a lower-level library.

Installation

If you are using Playwright with JavaScript/Node.js Tesults supplies a reporter specifically designed for Playwright to make integration quick and easy.

Install the playwright-tesults-reporter

npm install playwright-tesults-reporter --save

Configuration

Specify the playwright-tesults-reporter as one or one of many reporters to use in the playwright.conf.js file:

const config = {
  reporter: [['playwright-tesults-reporter', {'tesults-target': 'token'}]]
}

The 'token' above should be replaced with your Tesults target token, which you received when creating a project or target, and can be regenerated from the configuration menu.

Then run playwright as usual with the npx playwright test command.

Basic configuration complete

At this point the playwright-tesults-reporter will push results to Tesults when you run your playwright command. The tesults-target arg must be supplied to indicate which target to use.

Files generated by tests

Any files attached during a test using the built-in Playwright attach method (example below) will be automatically uploaded to Tesults for reporting.

Example of Playwright test code attaching files. Any files attached in this way in your tests will be automatically uploaded to Tesults.
await page.screenshot({path: 'screenshot.png', fullPage: true });
await testInfo.attach('screenshot.png', { path: 'screenshot.png' });
await testInfo.attach('otherpic.jpg', { path: '/Users/John/Desktop/picture1.jpg'});

Caution: If uploading files the time taken to upload is entirely dependent on your network speed. Typical office upload speeds of 100 - 1000 Mbps should allow upload of even hundreds of files quite quickly, just a few seconds, but if you have slower access it may take hours. We recommend uploading a reasonable number of files for each test case. The upload method blocks at the end of a test run while uploading test results and files. When starting out test without files first to ensure everything is setup correctly.

Handling multiple test jobs with targets

For supporting multiple test jobs Tesults suggests creating multiple targets, as outlined in the project structuring advice. There are several ways you could handle configuration for multiple targets within Playwright and we discuss one way here.

Utilize a .env file. Store multiple target tokens in the file, for example:

.env
# .env file
TARGET1=eyJ0eX...
TARGET2=eyJ0eY...
TARGET3=eyJ0eZ...

Then in your playwright.conf.js file you can utilize these values when you pass in the target to Tesults, for example:

playwright.conf.js
require('dotenv').config();
...
const config = {
  reporter: [['playwright-tesults-reporter', {'tesults-target': process.env.TARGET1}]]
}
...

You can create multiple playwright.conf.js files each referencing a different target and in your package.json file create scripts to run each one, for example:

package.json
...
"scripts": {
  "test-job-1": "npx playwright test --config=playwright.config1.js",
  "test-job-2": "npx playwright test --config=playwright.config2.js",
  "test-job-3": "npx playwright test --config=playwright.config3.js"
}, ...

Run the desired test job:

npm run test-job-1

Target

tesults-targetRequired

Required arg to upload to Tesults, if this arg is not provided the reporter does not attempt upload, effectively disabling it. Get your target token from the configuration menu in the Tesults web interface.

{'tesults-target': 'token'}

Build

tesults-build-nameOptional

Use this to report a build version or name for reporting purposes.

{'tesults-build-name': '1.0.0'}

tesults-build-resultOptional

Use this to report the build result, must be one of [pass, fail, unknown].

{'tesults-build-result': 'pass'}

tesults-build-descriptionOptional

Use this to report a build description for reporting purposes.

{'tesults-build-description': 'added new feature'}

tesults-build-reasonOptional

Use this to report a build failure reason.

{'tesults-build-reason': 'build error line 201 somefile.js'}

Result Interpretation

Result interpretation is supported by Playwright. Install version 1.0.1 or newer. If you use result interpretation we recommend you add these minimum mapping values:

passed
pass
failed
fail

Consolidating parallel test runs

If you execute multiple test runs in parallel or serially for the same build or release and results are submitted to Tesults within each run, separately, you will find that multiple test runs are generated on Tesults. This is because the default behavior on Tesults is to treat each results submission as a separate test run. This behavior can be changed from the configuration menu. Click 'Results Consolidation By Build' from the Configure Project menu to enable and disable consolidation by target. Enabling consolidation will mean that multiple test runs submitted with the same build name will be consolidated into a single test run.

Dynamically created test cases

If you dynamically create test cases, such as test cases with variable values, we recommend that the test suite and test case names themselves be static. Provide the variable data information in the test case description or other custom fields but try to keep the test suite and test name static. If you change your test suite or test name on every test run you will not benefit from a range of features Tesults has to offer including test case failure assignment and historical results analysis. You need not make your tests any less dynamic, variable values can still be reported within test case details.

Proxy servers

Does your corporate/office network run behind a proxy server? Contact us and we will supply you with a custom API Library for this case. Without this results will fail to upload to Tesults.

Have questions or need help? Contact us