At this point I am stubbing API endpoints with Cypress Intercept. It is working great, but I've the feeling I could use it more efficient.
Currently I have the following test:
cy.intercept('GET', '**/Classifications', { fixture: 'stubClassifications/Classifications5.json' })
cy.get('div.dropdown-menu.show').find('a.dropdown-item').should('have.length', 5)
It's working, and checks the file Classifications5.json where 5 classifications are available.:
Classifications5.json:
[
{
"id": "6a75b703-8af4-4734-8d3f-c259d36b7a5e",
"name": "1STUBTest EEO",
"hasChildren": false
},
{
"id": "6a75b703-8af4-4734-8d3f-c259d36b7a5e",
"name": "2STUBTest EEO",
"hasChildren": false
},
{
"id": "6a75b703-8af4-4734-8d3f-c259d36b7a5e",
"name": "3STUBTest EEO",
"hasChildren": false
},
{
"id": "6a75b703-8af4-4734-8d3f-c259d36b7a5e",
"name": "4STUBTest EEO",
"hasChildren": false
},
{
"id": "6a75b703-8af4-4734-8d3f-c259d36b7a5e",
"name": "5STUBTest EEO",
"hasChildren": false
}
]
In a following test I am stubbing the same API-endpoint but with just 1 classification, namely Classifications1.json.
As you can understand I made several .json file in the fixture map for each result that I am asserting and this doesn't look very nice and clean.
How can I prevent making multiple .json files in the map fixtures when using the cy.intercept for the same end-point.