Skip to content

Commit

Permalink
add descriptions for newly added cypress commands
Browse files Browse the repository at this point in the history
  • Loading branch information
alishaevn committed Feb 13, 2024
1 parent f5a064d commit 064dfa3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,21 @@ Cypress.Commands.add('customApiIntercept', ({
}).as(alias || 'customIntercept')
})

/**
* Intercept the useFilteredWares API call to modify the per_page query
* parameter. We're lowering it in an attempt to speed up the test. Then,
* we continue to hit the server with the modified request.
*/
Cypress.Commands.add('useFilteredWares', () => {
cy.intercept(/\/wares\.json\?per_page=2000&q.*/, (req) => {
req.url = req.url.replace(/per_page=\d+/, `per_page=${Cypress.env('API_PER_PAGE')}`)
req.continue()
})
})

/**
* To avoid the flakiness of the test, we wait for the element to exist
*/
Cypress.Commands.add('waitForElement', (selector) => {
cy.get(selector).should('exist')
})

0 comments on commit 064dfa3

Please sign in to comment.