Reusing spec.js files to reduce code and being more DRY
See original GitHub issueCurrent behavior:
- Create e.g. a
registration.spec.js
(does a full registration process) - Create e.g. a
offer.spec.js
(does click on a offer link and starts booking, then coming to the register page and doing a full registration process)
Desired behavior:
- Create e.g. a
registration.spec.js
(does a full registration process) - Create e.g. a
offer.spec.js
(does click on a offer link and imports theregistration.spec.js
)
Versions
Cypress 3.2.0 Ubuntu 18.04
Why that procedure?
Because I would like to reduce core. DRY principle. Is there a proper way to solve this. Or is rewriting specs and repeating stuff the best and already a proper way to solve this in cypress?
I was not able to find a good solution. The only way I could think of is to create a custom function. But with reusing spec.js
files I think this would be more modular.
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
What's a good way to reuse test code using Jasmine?
Here is an article by a guy at Pivotal Labs that goes into detail about how to wrap a describe call: DRYing up...
Read more >How to Maximize Your Ability to Reuse Code Across Projects
Code reuse is a critical technique for scalable application development. Here are some ways to reuse components across as many projects as ...
Read more >End-to-end Testing with Cypress Series: 06 DRY (Don't ...
In this video, learn about the DRY (Don't Repeat Yourself) principle and how it can affect end-to-end tests.
Read more >Stop using Page Objects and Start using App Actions - Cypress
Finally, the page objects to tests boundary is tight - because both levels are in the same code and can be checked by...
Read more >Create Reusable Web Components in HTML
These can then be reused multiple times as the basis of a custom element's ... To begin with, in our header.js file we...
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 FreeTop 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
Top GitHub Comments
Use simplified:
or if you like it relative:
Would be awesome to get just one hint on this. I think this is important for all the developers who want to write clean code and reusing code fragments.