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 :
JavaScript
x
35
35
1
it("should delete online absentee bid given its id", () => {
2
const absenteeBidId = Faker.random.number();
3
const absenteeBid = absenteeBidDataBuilder({ id: absenteeBidId });
4
const expectedDeletedAbsenteeBid = {
5
deleteAbsenteeBid: {
6
id: `${absenteeBidId}`
7
}
8
};
9
const graphqlQuery = {
10
query: `mutation {
11
deleteAbsenteeBid(
12
id: "${absenteeBidId}",
13
user_id: "${userId}",
14
) {
15
id
16
subscription_id
17
amount
18
}
19
}`
20
};
21
22
nock(onlineApiUrl)
23
.persist()
24
.log(console.log)
25
.delete(`/orders/${absenteeBidId}`)
26
.query({ user_id: userId })
27
.reply(StatusCodes.OK, absenteeBid);
28
29
return request
30
.post(GRAPHQL_URI)
31
.set(JWT, token)
32
.send(graphqlQuery)
33
.then(response => expectGraphqlResponse(response, expectedDeletedAbsenteeBid));
34
});
35
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:
JavaScript
1
2
1
user@local$ DEBUG=nock.* node my_test.js
2