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

Add option to run specs outside of cypress directory #1012

Closed
nwshane opened this issue Dec 5, 2017 · 5 comments
Closed

Add option to run specs outside of cypress directory #1012

nwshane opened this issue Dec 5, 2017 · 5 comments
Labels
stage: wontfix Cypress does not regard this as an issue or will not implement this feature

Comments

@nwshane
Copy link

nwshane commented Dec 5, 2017

  • Cypress Version: 1.1.3

Is this a Feature or Bug?

Feature

Current behavior:

Cypress only runs spec files within the directory cypress/integration.

Desired behavior:

The option to run files that match a certain glob, e.g. *.spec.js, outside of the cypress/integration directory.

Reasoning:

It's really nice to be able to place unit tests in the same directory as the module they are testing. When a new developer dives into a code base that colocates modules and their unit tests, they don't have to go searching for the tests in another directory.

Here's an article about the advantages of colocating unit tests: http://islovely.co/posts/colocating-unit-tests/

I couldn't find any documentation related to this feature, so I'm wondering: is this already possible? If not, could we add this feature?

@brian-mann brian-mann added the stage: wontfix Cypress does not regard this as an issue or will not implement this feature label Dec 5, 2017
@brian-mann
Copy link
Member

Cypress is specialized for e2e and integration tests. While you can do unit tests, it's not really our thing.

Globbing support is already on the roadmap here. #681

I'm going to mark this issue as wontfix but we'll keep it around when we come back to first class unit testing support.

@nwshane
Copy link
Author

nwshane commented Dec 5, 2017

@brian-mann Okay, thanks for the explanation!

@jaydeep987
Copy link

jaydeep987 commented Oct 21, 2019

@brian-mann
So it's already 2019, is it still working ?
--spec option is there, but why it behave strange?
cypress run --spec src/app/ui-components/button/__test/index.spec.js
and it says Can't run because no spec files were found.

I dont' get this

@jaydeep987
Copy link

@brian-mann
So it's already 2019, is it still working ?
--spec option is there, but why it behave strange?
cypress run --spec src/app/ui-components/button/__test/index.spec.js
and it says Can't run because no spec files were found.

I dont' get this

Ok I solved this.

I found that it is still unclear because probably lack of documentation.
So people who are still facing issues, can refer this: #2256

@maxmckenzie
Copy link

For my use case i needed

  "testFiles": "**/*.{feature,spec.js}",
  "integrationFolder": ".",
  "ignoreTestFiles": "**/node_modules/**/*{feature,spec.js}",

in my cypress.json config and it worked a charm.

I want to run integration tests from the cypress directory. But then place cypress unit tests next to the specific code file i am unit testing.

https://github.com/cypress-io/cypress-example-recipes/tree/master/examples/unit-testing__application-code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: wontfix Cypress does not regard this as an issue or will not implement this feature
Projects
None yet
Development

No branches or pull requests

5 participants