The Visual Reporter is a new feature introduced in the @wdio/visual-service
, starting from version v5.2.0. This reporter allows users to visualize the JSON diff reports generated by the Visual Testing service and transform them into a human-readable format. It helps teams better analyze and manage the visual testing results by providing a graphical interface for reviewing the output.
To utilize this feature, ensure you have the required configuration to generate the necessary output.json
file. This document will guide you through setting up, running, and understanding the Visual Reporter.
Prerequisites
Before using the Visual Reporter, make sure you have configured the Visual Testing service to generate JSON report files:
export const config = {
// ...
services: [
[
"visual",
{
createJsonReportFiles: true, // Generates the output.json file
},
],
],
};
For more detailed setup instructions, refer to the WebdriverIO Visual Testing Documentation or the createJsonReportFiles
Installation
To install the Visual Reporter, add it as a development dependency to your project using npm:
npm install @wdio/visual-reporter --save-dev
This will ensure the necessary files are available to generate reports from your visual tests.
Usage
Building the Visual Report
Once you have run your Visual tests and they generated the output.json
file, you can build the visual report using either the CLI or interactive prompts.
CLI Usage
You can use the CLI command to generate the report by running:
npx wdio-visual-reporter --jsonOutput=<path-to-output.json> --reportFolder=<path-to-store-report> --logLevel=debug
Required options:
--jsonOutput
: The relative path to theoutput.json
file generated by the Visual Testing service. This path is relative to the directory from which you execute the command.--reportFolder
: The relative directory where the generated report will be stored. This path is also relative to the directory from which you execute the command.
Optional options:
--logLevel
: Set todebug
to get detailed logging, especially useful for troubleshooting.
Example
npx wdio-visual-reporter --jsonOutput=/path/to/output.json --reportFolder=/path/to/report --logLevel=debug
This will generate the report in the specified folder and provide feedback in the console. For example:
✔ Build output copied successfully to "/path/to/report".