Day 11 - URL test is failing after submitting

I can’t get past day-11.
On “submit”, there’s only 1 test failing. It returns the following:

Tests added correctly | AssertionError: check watering url: expected ‘’ to equal ‘…

I checked the tests of the previous requests but I cannot find the error. I am attaching the screenshots. Help!

This is the code for the failing test.

pm.test("Tests added correctly", () => {
    let hygroRequest = collection.item[0].item.find(req => { return === "should I water the plants?"})
    pm.expect(hygroRequest.request.url.raw, 'check hygrometer url').equals("")
    pm.expect(hygroRequest.request.method, 'check hygrometer method').equals("GET")
    let hygroTest = hygroRequest.event.find(event => { return event.listen === "test" })
    pm.expect(hygroTest.listen, 'check test').equals("test")
    pm.expect(hygroTest.script.exec.toString(), 'check test syntax').includes("pm.test(")

    let waterRequest = collection.item[0].item.find(req => { return === "water the plants"})
    pm.expect(waterRequest.request.url.raw, 'check watering url').equals("")
    pm.expect(waterRequest.request.method, 'check watering method').equals("POST")
    pm.expect(waterRequest.request.body.mode, 'check watering body').equals("formdata")
    let waterTest = waterRequest.event.find(event => { return event.listen === "test"})
    pm.expect(waterTest.listen, 'check watering test').equals("test")
    pm.expect(waterTest.script.exec.toString(), 'check test syntax').includes("pm.test(")

    pass += 1

In particular, it appears to be this line.

    pm.expect(waterRequest.request.url.raw, 'check watering url').equals("")

It would appear that its getting the first part correct from your request name, but what I can’t ascertain is why its asserting against the wrong URL, considering the “” is hard coded.

It’s like its mixing the first and second tests in that code block.

I can only suggest that the request names have got mixed up somehow.

I would troubleshoot this by adding a few console logs to the above code block. Perhaps a “Hello World” after the the hygroRequest to see if its actually failing on the first or second block of code. If the hello world doesn’t show in the console log, then the issue is actually with the first test, not the second one.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.