Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The screenshot names are different when running All Integration Specs via the cy ui #67

Closed
Dassderdie opened this issue Jan 23, 2022 · 1 comment

Comments

@Dassderdie
Copy link

Dassderdie commented Jan 23, 2022

Setup

I use cypress@9.2.1 and cypress-image-diff-js@1.16.1.

I have a simple integration test in landing-page.spec.ts:

describe('The landing page', () => {
    it('is possible to make visual regression tests', () => {
        cy.visit('/');
        cy.get('.container').compareSnapshot('landing-page', 0.1);
    });
});

Bug description

If I start cypress via cypress run I get a screenshot with the name landing-page.spec.ts-landing-page.png.

If I start cypress via cypress open and click on Run 1 integration spec the resulting screenshot name is All Integration Specs-landing-page.png.

image

Some quick thoughts

I guess the relevant code is here

      const specName = Cypress.spec.name
      const testName = `${specName.replace('.js', '')}-${name}`

There are two issues:

  1. Cypress.spec.name doesn't seem to be the correct way to get the filename of the test
  2. there are more file endings than just .js

There also seems to be Cypress.currentTest.titlePath.

The solution from cypress-plugin-snapshots seems to also not rely on the file name of the tests, but the describe blocks? - No it seems to have the same problem.

function getTestTitle(test) {
  return (test.parent && test.parent.title ? `${getTestTitle(test.parent)} > ` : '') + test.title;
}
@Dassderdie
Copy link
Author

After a bit further investigation, it seems like this is a well-known bug: cypress-io/cypress#3090 and cypress-plugin-snapshots has actually a caveat in their readme about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant