This is a collection of reporters to use with our Playwright test frameworks.
- Retry reporter: Provides an easy way to retry failed tests on Jenkins or locally.
- Analytics reporter: Uploads test results and browser usage to ElasticSearch for further analysis.
- Add the package to your project:
npm install @lokalise/playwright-reporters
- Add the reporters to your Playwright configuration:
import { defineAnalyticsReporterConfig, defineRetryReporterConfig } from '@lokalise/playwright-reporters';
export default defineConfig({
...
reporters: [
['retry', defineRetryReporterConfig({ maxRetryCount: 2, isPREnv: false })],
['analytics', defineAnalyticsReporterConfig({
flakyTestIndex: 'flaky_tests_0001',
failedTestIndex: 'non_passing_tests_0001',
testRunIndex: 'test_run_0001',
browserUsageIndex: 'browser_usage_0001',
elasticUrl: 'http://elasticUrl',
elasticToken: 'elasticToken',
currentBuildId: 'buildId',
debug: true,
dryRun: false,
prenvId: 'develop',
product: 'product',
})],
],
...
});
This reporter aggregates the duration of each discrete test step and reports their total duration at the end of the test run. The reporter uses the custom Playwright Reporter implementation to collect the step durations. Follow the steps in the official Playwright documentation to add the custom reporter to your test suite.
Once the reporter is enabled, it will output a JSON
file ./reporters/results/steps.json
containing the duration of each step in the test suite.
This reporter calculates the similarity between tests based on the test steps. The reporter does not use the custom Playwright Reporter implementation. Instead, it takes the simplified reporter from the undocumented timeline
reporter.
- Run the test suite with the
timeline
reporter enabled. This will generate aJSON
file./reporters/results/timeline.json
- Run the similarity reporter with the following command:
npx ts-node reporters/testSimilarity.ts
- After analysing the results, the reporter will output a
JSON
file./reporters/results/distance.json
containing the similarity between tests based on the test steps.
The report has the following format:
[
{
"title": "Title of the test being compared",
"relatedTests": [
["Title of the first related test", 0],
["Title of the second related test", 50]
]
}
]
The relatedTests
array contains the title of the related test and the distance score. The similarity percentage is calculated based on the Levenshtein distance between the test steps. The lower the distance, the higher the similarity between the tests.
By default, pre-commit hook will run npm run lint:fix
. Feel free to remove that if it's undesirable or add your own
pre-commit commands.
Check out husky docs for more info.
You can use npm run commit
to interactively construct correct commit messsage.
Check out commitlint docs for examples of how to customise.
The following token needs to be set in the Github repo for the prerelease
and release
Github Actions to work:
-
secrets.NPM_TOKEN
(need this to publish on NPM)
When performing a release, make sure to follow our conventional commit approach, as described in contribution documentation.
This project is APACHE, VERSION 2.0 licensed, see LICENSE.md for details.