My question:
Hello Everyone.
Working on Day 13 challenge. I did everything requested and reached the submit request but having 2 errors in test Results which are:
FAIL
Requests added correctly | AssertionError: check number of requests: expected +0 to equal 2
FAIL
Tests and Scripts added correctly | TypeError: Cannot read properties of undefined (reading ‘event’)
Details (like screenshots):
Here details about tests I wrote for planets and species requests:
How Can I manage this situation?
This is the test that is failing.
pm.test("Requests added correctly", () => {
pm.expect(collection.item[0].item.length, 'check number of requests').equals(2)
let planetRequest = collection.item[0].item.find(req => { return req.name === "planets"})
pm.expect(planetRequest.name, 'check planet name').equals("planets")
pm.expect(planetRequest.request.method, 'check planet method').equals("GET")
pm.expect(planetRequest.request.url.raw, 'check planet url').includes("https://swapi.dev/api/planets")
let speciesRequest = collection.item[0].item.find(req => { return req.name === "species"})
pm.expect(speciesRequest.name, 'check species name').equals("species")
pm.expect(speciesRequest.request.method, 'check species method').equals("GET")
pm.expect(speciesRequest.request.url.raw, 'check species url').includes("https://swapi.dev/api/species")
pass += 1
})
In particular, I suspect it will be the references to the following
collection.item[0]
Which is causing both tests to fail.
This should bring back the “Newman” folder but I suspect for some reason, its not.
I would need to see the JSON returned in the “Submit” request to advise further.
Otherwise I would recommend cloning the submit request and adding a few console logs to the code.
console.log(collection.item[0]);
What does that return?