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

Inconsistent behavior of Cypress.spec in GUI mode #15077

Closed
Yethal opened this issue Feb 12, 2021 · 1 comment
Closed

Inconsistent behavior of Cypress.spec in GUI mode #15077

Yethal opened this issue Feb 12, 2021 · 1 comment
Labels
type: duplicate This issue or pull request already exists

Comments

@Yethal
Copy link

Yethal commented Feb 12, 2021

Current behavior

Cypress.spec.name is set to the relative path of the spec file when:

  • single spec file is ran in gui mode
  • single spec file is ran in cli mode
  • multiple spec files are ran in cli mode

However, when all spec files are ran in test runner via the "Run x integration specs button" Cypress.spec.name is set to "All Integration Specs".
In my application we need to set a few environment variables before every test suite and those variables correspond to the name of the subdirectories where the spec files are kept. Currently the variables are set like this:
let segment = Cypress.spec.name.split('\\')[0]
let country = Cypress.spec.name.split('\\')[1]
Because of this inconsistent behavior whenever we try to run all integration specs via gui runner Cypress throws an exception.

Desired behavior

Cypress.spec.name is set to the relative path of the spec file regardless of the manner in which tests were launched

Test code to reproduce

Link to fork:
https://github.com/Yethal/cypress-test-tiny

Versions

6.4.0

@bahmutov
Copy link
Contributor

Thank you for reporting the issue, this is a duplicate of #3090

For now, the workaround is described in meinaart/cypress-plugin-snapshots#10 (comment)

@bahmutov bahmutov added the type: duplicate This issue or pull request already exists label Feb 12, 2021
@cypress-io cypress-io locked and limited conversation to collaborators May 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants