It was a while ago since I wrote this..
If my memory serves me correct I believe a nock is considered used as soon as it is hit.
So you need to define a new nock definition... I'm gonna test it to make sure.. Thanks for the question
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great article - does the nock 'mock' only last for the duration of the single test ? e..g
it('renders without crashing', () => {
const scope = nock('myapi.com')
.get('/products')
.reply(200, { products: [{ id: 1, name: 'nocked data' }] },
{
'Access-Control-Allow-Origin': '*',
'Content-type': 'application/json'
});
const div = document.createElement('div');
ReactDOM.render(, div);
ReactDOM.unmountComponentAtNode(div);
});
if I added another test after that would the call to myapi.com/products go through nock without having to set it up?
Thanks
Jojm
It was a while ago since I wrote this..
If my memory serves me correct I believe a nock is considered used as soon as it is hit.
So you need to define a new nock definition... I'm gonna test it to make sure.. Thanks for the question