Skip to content

Instantly share code, notes, and snippets.

View potapovDim's full-sized avatar
🇺🇦

Potapov Dmitriy potapovDim

🇺🇦
View GitHub Profile
@potapovDim
potapovDim / gist:2d1acb698cc0db16b40ea8e912f5aec1
Last active July 31, 2020 13:44
mock request protractor example
// implementation
function mochRequest(requiredUrl, method, data) {
//@ts-ignore
const __fetchy = window.fetch;
//@ts-ignore
window.fetch = function(...args) {
const mockedInterface = {
text: () => Promise.resolve(typeof data === 'string' ? data : JSON.stringify(data)),
json: () => Promise.resolve(typeof data !== 'string' ? data : JSON.parse(data)),
};