I cannot for the life of me get nock to work with a simple superagent post request. Here is both my superagent and nock configuration.
superagent:
request
.post('https://test.com/api/login')
.send({
email: 'test@test.com',
password: 'testpassword'
})
.end((err, res) => {
if (err) {
console.log(err);
}
});
nock:
nock('https://test.com')
.post('/api/login')
.send({
email: 'test@test.com',
password: 'testpassword'
})
.reply(200, {
id: 1,
token: 'abc'
});
I'm receiving the following error from nock:
{ [Error: Nock: No match for request POST https://test.com/api/login {"email":"test@test.com","password":"testpassword"}] status: 404, statusCode: 404, response: undefined }
Another weird aspect is that this error is being logged in my superagent response handler. So I know the call is being made and intercepted.