Giter Club home page Giter Club logo

cypress-image-diff-html-report's Introduction

cypress-image-diff-html-report

Overview

A HTML reporting module for Cypress-Image-Diff to parse the JSON output into a beautiful report

Update baseline screenshots

Support different screenshot inspectors

Provide with light/dark/system default theme

Installation

Make sure you install Cypress and cypress-image-diff prior to this report installation.

npm install -D cypress-image-diff-html-report

Project setup

Once you've installed the package, you are good to go without any further configuration. However, you can create a configuration file if you do want more custom configurations. cypress-image-diff-html-report will look for the cypress-image-diff-html-report.config.js file under the root of your project.

You can use the defineConfig helper which provides intellisense:

import { defineConfig } from 'cypress-image-diff-html-report'

export default defineConfig({
  // config options
})

If you’d like to specify a different config filename than the default, use the --configFile command line option.

See all available configurations here.

CLI

This is the most common way to use cypress-image-diff-html-report. It supports two commands: generate and start.

  • generate: generates the HTML report and writes to disk wherever it's designated.

    cypress-image-diff-html-report generate [options]
    
  • start: starts a local server, which will serve the HTML report on the fly. You don't need to run generate before this command if you don't want to write the HTML report to your disk.

    cypress-image-diff-html-report start [options]
    

See all available CLI options here.

API

cypress-image-diff-html-report can be used to programmatically generate reports or start a local server. Whichever option is available via CLI is also available in the API. It is useful to use the API if you need more flexibility or to integrate with other third parties.

  • generate:

    import { generate } from 'cypress-image-diff-html-report'
    
    ;(async () => {
      await generate({
        configFile: 'custom.config.js',
        // ...
      })
    })()
    
  • start:

    import { start } from 'cypress-image-diff-html-report'
    
    ;(async () => {
      await start({
        configFile: 'custom.config.js',
        serverPort: 3000
        // ...
      })
    })()
    

See all available API options here.

Example integration

Run generate as soon as all the tests are executed.

// package.json
{
  "scripts": {
    "test:e2e": "cypress run --headless && cypress-image-diff-html-report generate --configFile my-visual-html-report.config.js"
  }
}

Often times you want to serve the HTML report locally to perform snapshot update features. Run the start command when the json report is in place:

cypress-image-diff-html-report start --configFile my-visual-html-report.config.js

All available options in the CLI, API, and config files

Config file options

Options Type Description Default value
reportJsonDir string Specify the report json directory, relative to the process.cwd(). Cypress-image-diff-html-report will automatically look for the latest created json file in this directory cypress-image-diff-html-report
reportJsonFilePath string Specify the report json file path, relative to the process.cwd(). If provided, reportJsonDir will be ignored undefined
outputDir string Set the output directory of the generated HTML report, relative to the process.cwd() cypress-image-diff-html-report
baseDir string Specify the base directory for all the interal paths in the report json, relative to the process.cwd(). (Note: This field does not have any effect on the configFile, reportJsonFilePath and outputDir) ''
inlineAssets boolean Whether to inline all screenshots to base64 for the generated HTML false
autoOpen boolean Open the HTML report in the default browser as soon as the server starts false
serverPort number Set the port of the local server 6868

Generate options

CLI API options Type Description Default value
-c, --configFile configFile string Specify config file, will be overwritten by other config options if provided, relative to the process.cwd() cypress-image-diff-html-report.config.js
--rd, --reportJsonDir <dir> reportJsonDir string Specify the report json directory, relative to the process.cwd(). Cypress-image-diff-html-report will automatically look for the latest created json file in this directory cypress-image-diff-html-report
--rf, --reportJsonFilePath <file> reportJsonFilePath string Specify the report json file path, relative to the process.cwd(). If provided, reportJsonDir will be ignored undefined
-o, --outputDir <dir> outputDir string Set the output directory of the generated HTML report, relative to the process.cwd() cypress-image-diff-html-report
--baseDir <dir> baseDir string Specify the base directory for all the interal paths in the report json, relative to the process.cwd(). (Note: This field does not have any effect on the configFile, reportJsonFilePath and outputDir) ''
--inlineAssets inlineAssets boolean Whether to inline all screenshots to base64 for the generated HTML false

Start options

CLI API options Type Description Default value
-c, --configFile configFile string Specify config file, will be overwritten by other config options if provided, relative to the process.cwd() cypress-image-diff-html-report.config.js
--rd, --reportJsonDir <dir> reportJsonDir string Specify the report json directory, relative to the process.cwd(). Cypress-image-diff-html-report will automatically look for the latest created json file in this directory cypress-image-diff-html-report
--rf, --reportJsonFilePath <file> reportJsonFilePath string Specify the report json file path, relative to the process.cwd(). If provided, reportJsonDir will be ignored undefined
--baseDir <dir> baseDir string Specify the base directory for all the interal paths in the report json, relative to the process.cwd(). (Note: This field does not have any effect on the configFile, reportJsonFilePath and outputDir) ''
--autoOpen autoOpen boolean Open the HTML report in the default browser as soon as the server starts false
--serverPort serverPort number Set the port of the local server 6868

cypress-image-diff-html-report's People

Contributors

kien-ht avatar semantic-release-bot avatar

Stargazers

David Serrano avatar vadym avatar Furkan Portakal avatar Zhazha_JiaYiZhen avatar vagusX avatar Greg Zhang avatar Wanpan avatar afc163 avatar Vladyslav Kozin avatar Mohamad Khajavi avatar  avatar  avatar Daniel avatar  avatar anta97 avatar  avatar Pippo Raimondi avatar  avatar

Watchers

 avatar Roman Tsymbal avatar  avatar

Forkers

davidewikicasa

cypress-image-diff-html-report's Issues

--inlineAssets creates invalid base64 images

Hi together,

When using the --inlineAssets option the images are base64 encoded. Unfortunately they can not be shown because there is some kind of version added to the end of it.

data:image/png;base64,[removed-image-data]?v=1712433107782

The version is also added when not using --inlineAssets, but then it is not an issue.
image

Unable to generate a combined HTML report

I am executing cypress-image-diff-js in parallel, resulting in multiple JSON files. My goal is to create a consolidated cypress-image-diff-html-report using all these JSON files.

Presently, when I run cypress-image-diff-html-report generate, only the latest JSON file is taken into account.

This is an urgent need. Appreciate any assistance here.

TIA!

Load Cypress Image Diff config file

I configured Cypress Image Diff to use a different report output.

cypress-image-diff.config.js

module.exports = {
    SCREENSHOTS_DIR: 'resources/screenshots',
    REPORT_DIR: 'target/reports/image-diff',
};

But the reporter does not load this file, I have to create another file to instruct the reporter of the folder.

It would be cool to be able to use the report tool without any additional configuration by setting reportJsonDir and outputDir to REPORT_DIR when found.

Feature request: Filter on failed tests

Hi there,

I really like the html report and it's easy setup. There would be one feature that would improve my usage a lot.
I have around 115 screenshot tests and when the pipeline step fails, I need to check them for issues.
Currently they are all listed and I need to search manually for the failed ones.
So a filter to only show the failed ones would be great.

Best Moritz

Unable to generate

I am trying this library, and regardless of what I do, it doesn't work.

I've tried running the command without any configuration, passing it inline or creating a configuration file with the required props, but nothing helps.

  cypress-image-diff-html-report generate -c reportJsonDir="./cypress-image-diff-html-report"

[cypress-image-diff-html-report]: Given reportJsonDir does not exist /home/develop/my-repo/cypress-image-diff-html-report. Make sure you specify a valid reportJsonDir or reportJsonFilePath

Folder configurations not effective

Actual behaviour:

I have the following cypress-image-diff-html-report.config.js (located in project root)

import { defineConfig } from 'cypress-image-diff-html-report'

export default defineConfig({
// config options
reportJsonDir: 'reports',
outputDir: 'reports',
baseDir : 'reports'
})

But the generated reports are written to
<project-root>/cypress-image-diff-html-report

Expected behaviour:

The configured folders have any effect, so that I can customize the file locations.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.