Doubt: load multiple fixtures once per Cypress execution
See original GitHub issueI have 3 sites, and each site has 3 envs, each with their config.json
and fixtures.json
. However, part of the fixture is common, like routes
which contains endpoints. Following the DRY pattern, I refactored the common bits to a routes.json
.
I basically want to load multiple fixtures…
- avoiding “pyramid of doom of fixtures”, as in this example
- if possible, once per Cypress execution (it’s a bit of a waste on a
before()
), unlike this example
Ideally I would be able to access each fixture file independently like:
cy.visit(routes.account.edit)
...
cy.get(selectorNotification).should("contain", keywords.dialog.success)
Given a file like:
// routes.json
{
"account": {
"edit": "/account/edit"
},
"users": {
"list": "/users",
"search": "/user/search"
},
...
}
I’ve tried a mix of cy.fixture
, Cypress.config
, fs.readFile
, cy.readFile
to no avail and now I’m too biased to think out of the box.
Please, can you advise me a solution? I feel like I’m over-engineering it.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (3 by maintainers)
Top Results From Across the Web
fixture | Cypress Documentation
Loaded just once. Please keep in mind that fixture files are assumed to be unchanged during the test, and thus Cypress loads them...
Read more >How to run the single test with different data set in parallel by ...
I just have the below spec file and It contains one It (Test case) and It will run multiple times based on the...
Read more >Load Fixtures from Cypress Custom Commands
This blog post multiples ways to pick a random item from a fixture file, and then reuse that picked item in multiple Cypress...
Read more >End-To-End Tutorial For Pytest Fixtures With Examples
Fixtures are a set of resources that have to be set up before and cleaned up once the Selenium test automation execution is...
Read more >What I've Learned Using Cypress.io for the Past Three Weeks
First place the image you would like to upload into the fixture folder, and then you would load the image data with cy.fixture...
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
Another solution could be to collect fixtures in a Promise The paths parameter is an array of paths to fixtures
Use like this:
This works:
But it’s annoying having to copy that whole block of boilerplate to every test file.