Playwright test reporting

Using the Playwright test framework? Follow the instructions below to report results. If you are not using Playwright please see the Node.js docs for integrating with a lower-level library.

Installation

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.

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'}

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