Light Reporter Reporter
wdio-light-reporter is a 3rd party package, for more information please see GitHub | npm
Inspired by HTML and Mochawesome reporter
Philosophy: This reporter does not support Cucumber report regeneration and is developed keeping in mind the BDD and Mocha framework. Here,
describe()section is considered as a test scenario andit()as a test case inside the test scenarios.
FEATURES
- Easy setup
- Enhanced UI with Bootstrap 5
- Screenshot embedded in HTML report
addLabel()to include step context or nameaddDetail()to add context at the scenario level- Multi-environment run support with environment-based segregation
- Expand/collapse all environments with tri-state checkbox
- Share / Save as PDF from the navbar
Releases
V 0.1.9 - Initial release V 0.2.6
- Include multiple environment runs and segregate based on environment.
- Fix bugs
- Improved performance. V 1.0.0 (latest)
- Redesigned UI with Bootstrap 5 and custom stat/chart cards.
- Environment cards with platform/browser icons and inline stats.
- Expand/collapse all with tri-state checkbox.
- Share button (Save as PDF).
- Responsive accordion headers that shrink before wrapping.
- Code cleanup and dead code removal.
Installation
NPM
npm install wdio-light-reporter --save-dev
Configuration
reporters: ['dot', ['light', {
outputDir: './Light_Results', // default: './Light_Results'
outputFile: 'demo', // html report filename (default: 'default')
addScreenshots: false, // embed screenshots in report (default: false)
}]
],
Screenshots
The reporter does not automatically take screenshots, but if manually configured, it listens to the event and attaches the screenshots in the HTML report.
To include screenshots in the report, add the below code in the afterTest() hook in your wdio conf file:
afterTest: async function (test, context, { error, result, duration, passed, retries }) {
if (!passed) { await browser.takeScreenshot() }
},
Result Files
Each run generates a JSON report for each spec file. To generate a combined JSON and HTML report, add the below code in the onComplete() hook in your wdio conf file:
onComplete: function (exitCode, config, capabilities, results) {
const mergeResults = require("wdio-light-reporter/src/mergeResults");
mergeResults("./Light_Results");
},
If you run your tests without any
--suiteoption, it considersdefaultas the suite. The reporter does not work if you provide multiple--suiteparameters in a single run.wdio run wdio.conf.js --suite firstSuite— (WORKS FINE) :)wdio run wdio.conf.js --suite firstSuite --suite secondSuite— (DOES NOT WORK) :(
Adding Context
addLabel() — Add step-level context
Use addLabel() to add context to any test step. It will appear as step info in the report.
const { addLabel } = require("wdio-light-reporter").default;
describe("Show how to use addLabel", () => {
it("report will add this as steps/context in report", async () => {
addLabel("Log Example 1 as step 1")
console.log("Log Example 1")
addLabel("Log Example 2 as step 2")
console.log("Log Example 2")
})
})
addDetail() — Add scenario-level context
Use addDetail() to add context at the scenario (describe) level.
const { addDetail } = require("wdio-light-reporter").default;
describe("Show how to use addDetail", () => {
addDetail("This context will appear at the scenario level")
it("some test case", async () => {
// ...
})
})
License
MIT Free, Hell Yeah!