Skip to content

Instantly share code, notes, and snippets.

@vedovelli
Created April 22, 2020 07:35
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save vedovelli/e85ccc9233b6d75d141682a6d1073e4d to your computer and use it in GitHub Desktop.
Cypress.on("window:before:load", win => {
win.handleFromCypress = function(request) {
return fetch(request.url, {
method: request.method,
headers: request.requestHeaders,
body: request.requestBody
})
.then(res => {
return new Promise(resolve => {
res.json().then(body => {
resolve({ body, status: res.status, headers: res.headers });
});
});
})
.then(({ body, status, headers }) => [status, headers, body]);
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment