Skip to content

Instantly share code, notes, and snippets.

@yagudaev
yagudaev / cypress_support_hooks.js
Last active Sep 16, 2021
Cypress Fetch Support Workaround - replaces fetch request with traditional XHR so cypress can track them
View cypress_support_hooks.js
// cypress/support/hooks.js
// Cypress does not support listening to the fetch method
// Therefore, as a workaround we polyfill `fetch` with traditional XHR which
// are supported. See: https://github.com/cypress-io/cypress/issues/687
enableFetchWorkaround()
// private helpers
function enableFetchWorkaround() {
let polyfill