I can’t force my whole life to work with a simple superagent email request. Here is my super-agent and night configuration.
SuperAgent:
request
.post('https://test.com/api/login')
.send({
email: 'test@test.com',
password: 'testpassword'
})
.end((err, res) => {
if (err) {
console.log(err);
}
});
nicks:
nock('https://test.com')
.post('/api/login')
.send({
email: 'test@test.com',
password: 'testpassword'
})
.reply(200, {
id: 1,
token: 'abc'
});
I get the following error from knock:
{[Error: Nock: there are no matches for the POST request https://test.com/api/login {"email": " test@test.com ", "password": "testpassword"}] status: 404, statusCode: 404, response: undefined}
Another strange aspect is that this error is logged in my super agent response handler. Therefore, I know that the call is being made and intercepted.