cypress-plugin-visual-regression-diff icon indicating copy to clipboard operation
cypress-plugin-visual-regression-diff copied to clipboard

Feat: Ability to remove space before #<attempt> in filename

Open jestapinski opened this issue 3 years ago • 2 comments

I'm looking to use this plugin with a framework (Bazel) that errors should files be passed with spaces in the filename which makes adoption quite complicated. Fortunately, I can provide options to remove most of the default spaces from the Cypress task etc., but this last space is hard coded. (i.e. some task name #0.png (the space before the #0)). This also might be tricky since spaces in filenames in general can be tricky to deal with.

Describe the solution you'd like A flag perhaps to toggle this space to be on or off (or some other character to be used)

Additional context Is there some quick workaround?

jestapinski avatar Dec 01 '22 20:12 jestapinski

Hey @jestapinski,

As a temporal workaround please use version 3.2.4-feat-spaces.0 release as a part of PR #199. Is that change enough for you? If yes, I will wait with it to get other big issues resolved, so there is only a single major version bump (changing filename would be a breaking change).

Also, can you provide me with all of the steps that were necessary to get rid of any spaces from image names? I would like add those to the documentation (maybe in the FAQ section). Of course, feel free to file a PR with that documentation addition by yourself if you want to 🙂

FRSgit avatar Dec 04 '22 23:12 FRSgit

Hey @FRSgit thanks for the speedy reply!

Looks good to me, see the _ as expected and so that is what I was expecting! To get everything else to omit the space, I passed the following option to matchImage:

{
  title: `${Cypress.currentTest.titlePath.join('_').replace(/\s/g, '_')}`,
}

Alternatively, we could have joined on ' ' since the replace would also catch that. The key is the replace. I can file a PR shortly to add that to the FAQ

jestapinski avatar Dec 05 '22 14:12 jestapinski