New nx workspace doesn't support custom cypress commands
See original GitHub issuePlease make sure you have read the submission guidelines before posting an issue
Expected Behavior
Adding a custom Cypress command with the generated schematics should not cause an error when the tests run.
Current Behavior
The custom commands aren’t registered to due supportFile: false
in the cypress.json file.
Failure Information (for bugs)
Adding the minimal steps to reproduce here: https://github.com/ca136/cypress-nx-commands/commit/d9991391140e6aa826b9242ab70ad04bfaf6bb40
Context
Please provide any relevant information about your setup:
Used nx 8.2.0
A minimal reproduce scenario using allows us to quickly confirm a bug (or point out coding problem) as well as confirm that we are fixing the right problem. see github repo above
Failure Logs
Either:
[tsl] ERROR in /Users/caleb.amsden/myapp/apps/myapp-e2e/src/integration/app.spec.ts(6,6)
TS2339: Property 'login' does not exist on type 'Chainable<undefined>'.
Or:
The support file is missing or invalid.
Your `supportFile` is set to `/Users/caleb.amsden/myapp/apps/myapp-e2e/src/support/index`, but either the file is missing or it's invalid. The `supportFile` must be a `.js` or `.coffee` file or, if you're using a preprocessor plugin, it must be supported by that plugin.
Correct your `cypress.json`, create the appropriate file, or set `supportFile` to `false` if a support file is not necessary for your project.
Learn more at https://on.cypress.io/support-file-missing-or-invalid
Other
Any other relevant information that will help us help you.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:15 (3 by maintainers)
Top Results From Across the Web
Share Cypress Commands in an Nx Workspace
In your Cypress setup, open the support/commands.ts file to see an example declaration of such a custom command: // eslint-disable-next-line @ ...
Read more >Share Cypress Commands in an Nx Workspace - YouTube
Nx has had strong Cypress support from the very beginning, by providing generators to automatically set Cypress up for new projects and even ......
Read more >Shared Cypress Assets in an Nx Workspace | by Preston Lamb
Many times Nx workspaces have multiple applications, and being able to share custom Cypress commands between the end to end test projects.
Read more >Cypress Component Testing does not use the ...
I am trying to set up cypress component testing in my NX workspace with an angular application. It does work so far, the...
Read more >@nrwl/cypress | Nx
If the @nrwl/cypress package is not installed, install the version that matches your nx package version. yarn add --dev @nrwl/cypress.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am facing the same issue, I have manually entered my support file path which is like this
"supportFile": "cypress/support/index.ts"
When I am running my cypress tests using test runner (ng e2e --watch) the tests are running fine. but when I am trying to run my tests using command line (ng e2e) it’s opening the browser for 4 minutes and not running any tests. I am just seeing the window in the below screenshot for 4 mins without any test execution.My folder structure contains .d.ts files for interfaces and .ts files for custom commands
Can some help me with this issue, I am actually stuck over here.
As @juristr mentions in another place, He found a solution:
If inside
commands.ts
you do something like:VScode will say, hey, there is a new command, I won’t give you a red wiggle anymore when you use it. Now, running
ng e2e
will say… what is thatdataCy
I don’t know about? But if inside the spec file where you use it, you do aimport ../support
(or your correct path to the support folder), it will actually find it and work.So you need to do two extra steps for a command. Create the type and import the file with the type where you use it. In a good world you only need to do the former and even better if it is in its own
d.ts
file.