kien-ht / cypress-image-diff-html-report

A HTML reporting module for Cypress-Image-Diff to parse the JSON output into a beautiful report
MIT License
18 stars 1 forks source link

Folder configurations not effective #6

Closed jamesdiener closed 2 months ago

jamesdiener commented 4 months ago

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.

tester-at-bmi commented 4 months ago

Also have the issue that i can't make te report to work.

My setup for reference.

cypress-image-diff.config.ts (project root)

const config = {
    ROOT_DIR: 'src/tests/e2e/cypress/test-results',
    CYPRESS_SCREENSHOT_OPTIONS: {
        capture: 'viewport'
    }
};

module.exports = config;

cypress-image-diff-html-report.config.ts (project root)

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

export default defineConfig({
    reportJsonDir: 'src/tests/e2e/cypress/test-results/cypress-image-diff-html-report'
});

or

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

export default defineConfig({});

When i try to generate the report

$ npx cypress-image-diff-html-report generate
[cypress-image-diff-html-report]: Given reportJsonDir does not exist C:\Users\John\projecten\project\cypress-image-diff-html-report. Make sure you specify a valid reportJsonDir or reportJsonFilePath
kien-ht commented 2 months ago

@tester-at-bmi should be cypress-image-diff.config.js and cypress-image-diff-html-report.config.js, in .js extension

@jamesdiener I did some investigation about this situation. It turns out that you have provided the wrong path to the source report json, instead of exit and throwing an error, the plugin actually proceeds with the default config, which is unintentional. I'll create a pull request for this bug shortly. However, as long as you provide a valid directory to the source json, everything should be fine.

In your case, <project-root>/reports seems to not exist. I don't know what you have in your cypress-image-diff.config.js file, but you should specify REPORT_DIR, this is to tell cypress-image-diff where to spit out the json, and reportJsonDir in cypress-image-diff-html-report.config.js is to tell where to pick it up. You should have them both stated.

Note: baseDir should be removed from your setup. baseDir is there to only specify the relative difference in hierarchy between the roots of cypress-image-diff-html-report and cypress-image-diff, refer to this docs. As long as you have the cypress-image-diff and cypress-image-diff-html-report live under the same directory, you never need baseDir. Maybe baseDir is not a precise choice of word for this variable, we'll rename it in the next breaking change.

github-actions[bot] commented 2 months ago

:tada: This issue has been resolved in version 2.1.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: