Created
December 2, 2019 16:53
-
-
Save gma/bef195bb5433df284b4f75bec38c9cc1 to your computer and use it in GitHub Desktop.
Stubbing XHR in Cypress
This file contains hidden or 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
import axios from 'axios'; | |
describe('Cypress', function() { | |
it('stubs a GET request', function() { | |
cy.server(); | |
const endpoint = 'http://my-api-host/path'; | |
cy.route('GET', endpoint, { | |
attr: [{ thing: 1234 }] | |
}); | |
axios.get(endpoint).then(response => { | |
console.log(response); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment