it('should demonstrate response overwrite with static data', () => {
const mock = browser.mock('https://todo-backend-express-knex.herokuapp.com/', {
method: 'get'
})
mock.respond([{
title: 'Injected (non) completed Todo',
order: null,
completed: false
}, {
title: 'Injected completed Todo',
order: null,
completed: true
}], {
statusCode: 200,
fetchResponse: true
})
browser.url('https://todobackend.com/client/index.html?https://todo-backend-express-knex.herokuapp.com/')
$('#todo-list li').waitForExist()
console.log($$('#todo-list li').map(el => el.getText()))
})
it('should demonstrate response overwrite with dynamic data', () => {
const mock = browser.mock('https://todo-backend-express-knex.herokuapp.com/')
mock.respond((request) => {
if (request.body.username === 'test') {
return { ...request.body, foo: 'bar' }
}
return request.body
}, {
statusCode: () => 200,
headers: () => ({ foo: 'bar }),
fetchResponse: false
})
})