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
26 stars 2 forks source link

Load Cypress Image Diff config file #5

Closed mistic100 closed 8 months ago

mistic100 commented 9 months ago

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.

kien-ht commented 8 months ago

Hi @mistic100 , so, in cypress-image-diff.config.js, we use REPORT_DIR to let Cypress Image Diff know where to dump the JSON. Then, in cypress-image-diff-html-report.config.js, you'll find reportJsonDir, which points to where Cypress Image Diff Html Report should find that JSON.

Why the separation? We intentionally split the reporting part from the core Cypress Image Diff to create two standalone packages. We didn't want settings in one inadvertently impacting the behavior of the other, keeping things clean and straightforward.

If you don't want a separate config file for this report, you could pass them on the fly as you trigger the report via CLI or API, see more here

mistic100 commented 8 months ago

I don't think it is straightforward to have to declare the same configuration twice. Having a sensible default value that "just works" seems reasonable. And it won't change anything for people wanting explicitly seperate folders.

kien-ht commented 8 months ago

I totally get your point. I agree that having to declare the same configuration twice isn't the best, and a sensible default value would make things easier.

However, the catch is that the suggestion works only for users with the config in the default folder. If someone has a custom config folder (not in the cwd), Cypress Image Diff Html Report struggles to locate it because at the end of the day, only Cypress Image Diff fully knows where to find its config file. So, in practice, it only streamlines things for users with the default config setup. Now we're back to square one where we would say, things are only "convenient" for users who want a default config, if you want to customize, you might as well have a proper config.

I'll close this issue for now. If additional users bring up similar concerns or express dissatisfaction with the current setup, we can revisit and consider implementing changes based on a broader user usage.