You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 22, 2024. It is now read-only.
Another use case for this - asserting on request properties in the test body:
fancy.nock('https://example.com',(api,ctx)=>api.get('/api/resource').reply(function(uri,requestBody){ctx.req=this.req;return{};}).it('should include auth in the header',ctx=>{expect(ctx.req.headers).to.have.property('authorization').that.matches(/Bearer/i)})
I know that I could write the same assertion using the nock's reqheaders property:
fancy.nock('https://example.com',{reqheaders: {'authorization': /Bearer/i}},api=>api.get('/api/resource').reply(200,{})).it('should include auth in the header')
But that makes the assertion implicit - when the test has more code before the .it() line it's not immediately obvious that the request headers are the main thing this test is designed to verify.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
It would be quite useful to have access to the context object when setting up nock responses:
The text was updated successfully, but these errors were encountered: