Playwright
Playwright is a robust testing framework that enables dependable end-to-end and cross-browser testing for web applications. It offers support for major web browsers like Chromium, Firefox, and WebKit. With Playwright, developers can utilise a unified API to interact with web browsers and write tests that can be executed across multiple browsers without the need for separate code for each browser.
CodeceptJS
CodeceptJS is a modern test automation framework that seamlessly integrates with different testing frameworks, such as Playwright, to simplify end-to-end testing for web, mobile, and desktop applications, including Electron.js. It provides a user-friendly syntax and a comprehensive range of features for effortlessly creating and executing automated tests.
Allure Report
Allure Report is a flexible and lightweight tool for generating and viewing clear graphical reports. It supports multiple languages and the majority of test frameworks. The Allure reports can be customised by adding additional metadata to the test cases, such as tags, labels, or descriptions. Integrating Allure Report with a CI/CD pipeline makes it useful for any automation process. With Allure Report, you can easily view and share test reports, enhancing collaboration and improving the overall testing process.
Install Allure Report
Install Allure Report executable to run locally on your development machine. The command below installs allure on macOS. Please follow the documentation to install on your operating system.
Ensure you have relatively latest version of Java SDK installed on your system and JAVA_HOME variable is configured properly as Allure Report requires Java runtime to run a local web server.
This will make allure executable accessible in your terminal. However, if you choose to install it using npm, it will be accessible within your project and you will need to create an npm script to run it. This is what most projects need.
Install CodeceptJS Allure helper
Allure Report is integrated with CodeceptJS tests using an official plugin. Install allure-codeceptjs as an NPM dependency by running npm install command.
Modify your codecept.conf.ts configuration file to include Allure Report helper.
As it is quite common to extend CodeceptJS using helpers as well, ensure that this configuration is added as a plugin and NOT a helper. Otherwise, the error below will be displayed.
Generate reports
The report in HTML format can be generated by runningallure generate command.
Use allure-patch, a handy utility from the community to combine Allure Report output results into a single HTML file.
View reports
Make sure tests are run and reports are generated. To view generated reports spin up the local web server and a new tab will automatically open browser window with interactive reports UI.
The process needs to be restarted for new scenarios to be available in the reporting UI. If you have specified a custom location for the reports, use allure open command.
Deploy Allure Report to GitHub Actions pipeline
As now we can generate a static HTML bundle with a single HTML file, we can host it on the web, say using GitHub Pages. To achieve deployment to GitHub Pages, navigate to your GitHub repository Settings and click on Pages tab.
<image>
Select GitHub Actions as the Source in Build and deployment section.
Configure GitHub Actions pipeline
Create a new YAML pipeline file in .github/workflows folder or add a new job to your existing pipeline.
Once we have GitHub Actions pipeline configured, executed and deployed, we can see the GitHub Pages url.
Please refer to CodeceptJS Playwright Typescript Boilerplate for the complete configuration for the pipeline.
A sample Allure Report deployment is available in https://bear-plus.github.io/codeceptjs-playwright-typescript-boilerplate.
Keep historical data
We can enhance our Allure Report output with historical data that can be stored for each test scenario and later examined to give extra insights of how test scenarios are performing over time. To achieve this, we can use a custom GitHub Action called Allure Report with history.
Update your GitHub repository Settings by clicking on Pages tab and switch Source to Deploy from a branch.
Select gh-pages branch or create one if you do not have it already.
Configure your GitHub Actions job steps as described in the allure-report-action documentation.
Summary
Comprehensive reports play a crucial role in end-to-end testing as they offer valuable insights into test results, enabling the identification of issues and areas for improvement. This article shows how we can achieve End-to-End test reporting with CodeceptJS, Playwright and Allure Report and deploy it to GitHub Pages.
Source code
The approach described in this article is implemented in CodeceptJS Playwright Typescript Boilerplate and available in Bear Plus GitHub space.
A sample Allure Report deployment is available in https://bear-plus.github.io/codeceptjs-playwright-typescript-boilerplate.