Playwright Testmo Reporter is a specialized test reporter designed for integration with the Testmo test management SaaS platform. It's crafted to generate a JUnit XML file that includes test steps, links to attachments, and details of fails, passes, etc. The project is written in TypeScript and aims to provide a seamless and lightweight experience.
- JUnit XML File Generation: Includes detailed test steps, attachments, and statuses.
- Easy Integration: Only requires a simple installation and configuration.
-
Lightweight: Utilizes a single dependency (
fast-xml-parser
) to generate XML data. - Well-maintained Code: Adheres to coding standards and continuously receives updates.
- Verified Implementation: Contacts with Testmo to ensure the implementation meets quality standards.
Installing the Playwright Testmo Reporter is a breeze. Simply run the following command:
npm install --save-dev playwright-testmo-reporter
To configure the reporter, add it to your playwright.config.ts
file. That's all you need to do to set it up!
Example playwright.config.ts
file:
import { TestmoReporterOptions } from "playwright-testmo-reporter";
...
reporter: [
[
'playwright-testmo-reporter',
{
outputFile: 'testmo/testmo.xml', // Optional: Output file path. Defaults to 'testmo.xml'.
embedBrowserType: false, // Optional: Embed browser type in the XML file. Defaults to false.
embedTestSteps: true, // Optional: Embed test steps in the XML file. Defaults to true.
testStepCategories: ["hook","expect","pw:api","test.step"], // Optional: Test step categories to include in the XML file. Defaults to ["hook","expect","pw:api","test.step"]. Possible options are "hook", "expect", "pw:api", "test.step".
testTitleDepth: 1, // Optional: Test case title depth to report in the XML file. Defaults to 1. Increase this to 2 include suite name. Increase this even further to include the path.
includeTestSubFields: false, // Optional: Include test sub fields in the XML file. Defaults to false.
attachmentBasePathCallback: (basePath) => `http://playwright-s3.services.mycompany.example:9000/test/${TEST_RUN_UUID}/` + basePath.split(/[\\/]/g).join('/'), // Optional: Specify a callback which accepts and returns a string to generate a custom attachment base path. Useful for referring to an artifact storage location for example.
} satisfies TestmoReporterOptions
]
]
...
Or for JavaScript, example playwright.config.js
file:
...
reporter: [
[
'playwright-testmo-reporter',
{
outputFile: 'testmo/testmo.xml', // Optional: Output file path. Defaults to 'testmo.xml'.
embedBrowserType: false, // Optional: Embed browser type in the XML file. Defaults to false.
embedTestSteps: true, // Optional: Embed test steps in the XML file. Defaults to true.
testStepCategories: ["hook","expect","pw:api","test.step"], // Optional: Test step categories to include in the XML file. Defaults to ["hook","expect","pw:api","test.step"]. Possible options are "hook", "expect", "pw:api", "test.step".
testTitleDepth: 1, // Optional: Test case title depth to report in the XML file. Defaults to 1. Increase this to 2 include suite name. Increase this even further to include the path.
includeTestSubFields: false, // Optional: Include test sub fields in the XML file. Defaults to false.
attachmentBasePathCallback: (basePath) => `http://playwright-s3.services.mycompany.example:9000/test/${TEST_RUN_UUID}/` + basePath.split(/[\\/]/g).join('/'), // Optional: Specify a callback which accepts and returns a string to generate a custom attachment base path. Useful for referring to an artifact storage location for example.
}
]
]
...
Once installed and configured, all you have to do is run your tests:
# Run all tests
npx playwright test
The rest works like magic. You'll have the JUnit XML file generated with all the required details.
After the tests have run, you need to use the Testmo CLI tool to import the data into Testmo.
-
Required:
fast-xml-parser
-
Peer Dependencies:
@playwright/test
,playwright-core
(usually already installed in a Playwright project)
You can find the package on NPM at playwright-testmo-reporter.
For any issues, queries, or contributions, please refer to the official repository or reach out to the Testmo contacts provided in the package documentation.
Please refer to the license file in the repository for information on the usage terms and conditions.
Happy Testing with Playwright and Testmo! 🚀