I am trying to get more info on why my nock mock is not right, but I can’t make the persist().log()
work.
Here is the test :
it("should delete online absentee bid given its id", () => { const absenteeBidId = Faker.random.number(); const absenteeBid = absenteeBidDataBuilder({ id: absenteeBidId }); const expectedDeletedAbsenteeBid = { deleteAbsenteeBid: { id: `${absenteeBidId}` } }; const graphqlQuery = { query: `mutation { deleteAbsenteeBid( id: "${absenteeBidId}", user_id: "${userId}", ) { id subscription_id amount } }` }; nock(onlineApiUrl) .persist() .log(console.log) .delete(`/orders/${absenteeBidId}`) .query({ user_id: userId }) .reply(StatusCodes.OK, absenteeBid); return request .post(GRAPHQL_URI) .set(JWT, token) .send(graphqlQuery) .then(response => expectGraphqlResponse(response, expectedDeletedAbsenteeBid)); });
Stackoverflow wants me to add some more details to be able to post this question, but I don’t know what to tell you more than that.
Advertisement
Answer
.log
was removed in Nock v13 because it didn’t provide much info when debugging.
https://github.com/nock/nock/blob/main/migration_guides/migrating_to_13.md#breaking-changes
Instead, you want to use DEBUG
get more info on why a particular request is not being matched. https://github.com/nock/nock#debugging
Do something like:
user@local$ DEBUG=nock.* node my_test.js