Created
July 29, 2019 20:10
-
-
Save subtleGradient/dbb15536ce7585a2bd3c93ceaef11af4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cypress.Commands.add('waitForAllAPIs', waitForAllAPIs); | |
let requestCount; | |
beforeEach(() => { | |
requestCount = 0; | |
cy.server({ | |
onRequest() { | |
requestCount++; | |
}, | |
onResponse() { | |
setTimeout(() => requestCount--, 0); | |
} | |
}); | |
}); | |
export const waitForAllAPIs = () => { | |
cy.log('Waiting for pending API requests:'); | |
cy | |
.shouldRetry(() => { | |
expect(requestCount).to.eq(0); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment