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

Module API: cypress.run is unable to pick a specific test from within the integration folder #14532

Closed
borecz opened this issue Jan 13, 2021 · 4 comments · Fixed by #14810
Closed
Assignees
Labels
type: unexpected behavior User expected result, but got another

Comments

@borecz
Copy link

borecz commented Jan 13, 2021

Cypress 6.2.1

Simple setup:

cypress.run({ spec: 'gtm/osp/track-ecommerce.events.spec.ts', configFile: 'cypress/config/configFiles/cypress-mobile.json' })

or
cypress.open({ configFile: 'cypress/config/configFiles/cypress-mobile.json' })

When I use cypress.open it correctly finds all the spec files (screenshot)

image

looking for this specific spec

image

image

@borecz
Copy link
Author

borecz commented Jan 28, 2021

any updates on this?

@bahmutov
Copy link
Contributor

The way --spec CLI parameter and cypress.run({ spec: ... }) value work is different from what you select in the Cypress Desktop GUI search box.

  • inside the search box we already use the Cypress integration folder setting and ignore test files pattern to show just the specs. Thus we do not show the typical "cypress/integration" folder
  • when using --spec CLI parameter you typically are in the terminal at the root of the project. For example let's say we are in the folder ~/git/cypress-test-tiny and want to run a spec. The specs are in the folder cypress/integration/ui folder. Our files:
$ ls -R cypress/integration
ui

cypress/integration/ui:
spec.js

So you are typing the command, and it makes sense to use the shell's path to the spec file - this way I can type the spec filename quickly

spec-cli.mp4

Even if you are outside the Cypress folder, you can use the relative path from the current path this way. For example, if I am in ~/git folder and my project is in ~/git/cypress-test-tiny

$ ./cypress-test-tiny/node_modules/.bin/cypress run \
  --project ~/git/cypress-test-tiny \
  --spec ./cypress-test-tiny/cypress/integration/ui/spec.js 

The same thing happens with cypress.run({ spec: ... }) option. You need to use the relative path from the current folder. Some code editors even help you by showing the relative path popups, for example like my VSCode here

spec-option.mp4

Finally, I will keep this ticket open:

  • I want to clarify this in our documentation
  • it would be super helpful to show the current folder in the error message to make the error understandable and remove the confusion

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jan 29, 2021

The code for this is done in cypress-io/cypress#14810, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Feb 1, 2021

Released in 6.4.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v6.4.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Feb 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: unexpected behavior User expected result, but got another
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants