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

cypress-split: there are 0 found specs #119

Closed
denis-domanskii opened this issue Oct 12, 2023 · 5 comments · Fixed by #122
Closed

cypress-split: there are 0 found specs #119

denis-domanskii opened this issue Oct 12, 2023 · 5 comments · Fixed by #122
Labels

Comments

@denis-domanskii
Copy link

denis-domanskii commented Oct 12, 2023

Hi! I faced the issue with finding the specs. cypress-split found 0 of them.

❯ DEBUG=cypress-split,find-cypress-specs SPLIT=1 SPLIT_INDEX=0 cypress run --e2e --config-file tests/cypress/cypress.config.ts --browser chrome --reporter teamcity

DevTools listening on ws://127.0.0.1:57041/devtools/browser/25c7f080-b912-404f-a87c-c51eb6213e55
  cypress-split Cypress config env +0ms
  cypress-split {
  cypress-split   'cypress-plugin-snapshots': '{"autoCleanUp":false,"autopassNewSnapshots":true,"diffLines":3,"excludeFields":[],"formatJson":true,"ignoreExtraArrayItems":false,"ignoreExtraFields":false,"imageConfig":{"createDiffImage":true,"resizeDevicePixelRatio":true,"threshold":0.1,"thresholdType":"percent"},"normalizeJson":true,"prettier":true,"prettierConfig":{"html":{"parser":"html","tabWidth":2,"endOfLine":"lf"}},"screenshotConfig":{"blackout":[],"capture":"fullPage","clip":null,"padding":null,"disableTimersAndAnimations":true,"log":false,"scale":false,"timeout":30000},"serverEnabled":false,"serverHost":"localhost","serverPort":2121,"token":"xxx-token-xxx","updateSnapshots":false,"backgroundBlend":"difference","name":""}'
  cypress-split } +1ms
  find-cypress-specs finding specs of type e2e +0ms
  find-cypress-specs Cypress version 13.3.0 +0ms
  find-cypress-specs treating options as Cypress version 13 +0ms
  find-cypress-specs config has "e2e" property, treating as Cypress v10+ +1ms
  find-cypress-specs findCypressSpecsV10 +0ms
  find-cypress-specs options v10 { specPattern: 'tests/cypress/integration/**/*.spec.ts*', excludeSpecPattern: '**/*.spec.ts.snap' } +0ms
  find-cypress-specs globby options tests/cypress/integration/**/*.spec.ts* { sort: true, ignore: [ '**/*.spec.ts.snap' ], absolute: true } +0ms
  find-cypress-specs found 0 file(s) [] +6ms
  find-cypress-specs ignore patterns [ '**/*.spec.ts.snap' ] +0ms
  find-cypress-specs filtered 0 specs +0ms
  find-cypress-specs  +0ms
cypress-split: there are 0 found specs

I read that cypress-split is based on find-cypress-specs, so I ran it separately from the same dir and it found all the specs:

❯ DEBUG=find-cypress-specs CYPRESS_CONFIG_FILE=tests/cypress/cypress.config.ts npx find-cypress-specs

  find-cypress-specs arguments { _: [] } +0ms
  find-cypress-specs found file tests/cypress/cypress.config.ts +0ms
  find-cypress-specs loading Cypress config from /Users/denis.domanskii/git/my-app/tests/cypress/cypress.config.ts +54ms
  find-cypress-specs returning default export as config from ./tests/cypress/cypress.config.ts +619ms
  find-cypress-specs finding specs of type e2e +0ms
  find-cypress-specs treating options as Cypress version 10 +0ms
  find-cypress-specs config has "e2e" property, treating as Cypress v10+ +0ms
  find-cypress-specs findCypressSpecsV10 +1ms
  find-cypress-specs options v10 { specPattern: 'tests/cypress/integration/**/*.spec.ts*', excludeSpecPattern: '**/*.spec.ts.snap' } +0ms
  find-cypress-specs globby options tests/cypress/integration/**/*.spec.ts* { sort: true, ignore: [ '**/*.spec.ts.snap' ], absolute: false } +0ms
  find-cypress-specs found 38 file(s) [ 'tests/cypress/integration/anchors.spec.ts', 'tests/cypress/integration/basic-types.spec.ts', ... ] +7ms
  find-cypress-specs ignore patterns [ '**/*.spec.ts.snap' ] +10ms
  find-cypress-specs filtered 38 specs +2ms
  find-cypress-specs tests/cypress/integration/anchors.spec.ts
  find-cypress-specs tests/cypress/integration/basic-types.spec.ts
  ...

In both scenarios it definitely reads the custom config file, because specPattern is correct. But something is wrong in cypress-split <-> find-cypress-specs interaction. I tried cypress-on-fix, but nothing changed. Also I tried to explicitly pass CYPRESS_CONFIG_FILE env variable to cypress, but nothing change too.

@denis-domanskii
Copy link
Author

denis-domanskii commented Oct 12, 2023

Ok, I just found the issue. I have the following project structure:

my-app/
├── frontend
├── tests/
│   └── cypress/
│       ├── integration/
│       │   └── super.spec.ts
│       ├── cypress.config.js
│       └── package.json
└── package.json

My root package.json contains script

    "cy:test": start-server-and-test 'yarn start-test-server' http-get://localhost:7072 'SPLIT=1 SPLIT_INDEX=0 cypress run --e2e --config-file tests/cypress/cypress.config.ts --browser chrome --reporter teamcity'",

And cypress.config.ts have the following specPattern:

    specPattern: 'tests/cypress/integration/**/*.spec.ts*',

With such setup cypress-split doesn't work, showing 0 specs, when running it from the project root dir using the npm script above. And find-cypress-specs works perfect.

But when I change specPattern to

    specPattern: 'integration/**/*.spec.ts*',

'cypress-split' found all the specs and run it. So, for some reason, it's not dir-agnostic and I'd say it's an issue.

@bahmutov
Copy link
Owner

The problem is when cypress-split executes, it runs inside Cypress. Cypress changes the working directory to the same folder as the config file. So from tests/cypress the path 'tests/cypress/integration/**/.spec.ts' makes no sense, right? I think Cypress itself has a fallback in this case, but regular globby inside find-cypress-specs does not. When you run find-cypress-specs by itself, you are running from the root folder, so it makes sense to find the specs. I need to think how to better solve this

@bahmutov
Copy link
Owner

Let me see if I can fix this, I added something in bahmutov/find-cypress-specs#188 for this

@github-actions
Copy link

🎉 This issue has been resolved in version 1.5.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This issue has been resolved in version 1.5.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

2 participants