2.1.2 • Published 17 days ago

cypress-image-diff-html-report v2.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
17 days ago

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

OptionsTypeDescriptionDefault value
reportJsonDirstringSpecify 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 directorycypress-image-diff-html-report
reportJsonFilePathstringSpecify the report json file path, relative to the process.cwd(). If provided, reportJsonDir will be ignoredundefined
outputDirstringSet the output directory of the generated HTML report, relative to the process.cwd()cypress-image-diff-html-report
baseDirstringSpecify 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)''
inlineAssetsbooleanWhether to inline all screenshots to base64 for the generated HTMLfalse
autoOpenbooleanOpen the HTML report in the default browser as soon as the server startsfalse
serverPortnumberSet the port of the local server6868

Generate options

CLIAPI optionsTypeDescriptionDefault value
-c, --configFileconfigFilestringSpecify 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>reportJsonDirstringSpecify 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 directorycypress-image-diff-html-report
--rf, --reportJsonFilePath <file>reportJsonFilePathstringSpecify the report json file path, relative to the process.cwd(). If provided, reportJsonDir will be ignoredundefined
-o, --outputDir <dir>outputDirstringSet the output directory of the generated HTML report, relative to the process.cwd()cypress-image-diff-html-report
--baseDir <dir>baseDirstringSpecify 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)''
--inlineAssetsinlineAssetsbooleanWhether to inline all screenshots to base64 for the generated HTMLfalse

Start options

CLIAPI optionsTypeDescriptionDefault value
-c, --configFileconfigFilestringSpecify 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>reportJsonDirstringSpecify 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 directorycypress-image-diff-html-report
--rf, --reportJsonFilePath <file>reportJsonFilePathstringSpecify the report json file path, relative to the process.cwd(). If provided, reportJsonDir will be ignoredundefined
--baseDir <dir>baseDirstringSpecify 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)''
--autoOpenautoOpenbooleanOpen the HTML report in the default browser as soon as the server startsfalse
--serverPortserverPortnumberSet the port of the local server6868
2.1.2

17 days ago

2.1.1

27 days ago

2.0.3

1 month ago

2.1.0

28 days ago

2.0.2

6 months ago

2.0.1

7 months ago

2.0.0

7 months ago

1.4.1

7 months ago

1.4.0

7 months ago

1.3.2

7 months ago

1.3.1

7 months ago

1.3.0

7 months ago

1.2.0

7 months ago

1.1.0

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago