Hi,
I am working on the “Day 02: Collections and environments” in the “30 days of Postman - for developers”.
When I submitted my solution, I came across the “New request added | AssertionError: check parameters: expected 1 to equal 2” error.
It seems that I set up everything correctly. Please refer to the following screen shots.
Could someone advise me how to resolve this error?
Best,
The screenshots posted have nothing to do with the failing test.
You need to show the request(s) from the collection.
The relevant info from the documentation…
Add a request: Rename the request from echo
to POST raw text
. Then, duplicate the request in this folder, and rename the second request GET with query params
. Update the new request HTTP method to GET
and update the request URL from /post
to /get
. Add two query parameters. This can be anything you like, for example, foo
and bar
or name
and ferret
. Send to make sure you get a 200 status code.
The important part being.
Add two query parameters. This can be anything you like, for example, foo
and bar
or name
and ferret
. Send to make sure you get a 200 status code.
When you have failing tests, I can only suggest that you look at the scripting tabs of the submit request and look for the failing test to understand more about what the failing test is actually doing.
pm.test("New request added", () => {
pm.expect(folder.item.length, 'check number of requests').equals(2)
let newRequest = folder.item.find(req => { return req.name === "GET with query params"})
pm.expect(newRequest.name, 'check name').equals("GET with query params")
pm.expect(newRequest.request.method, 'check method').equals("GET")
pm.expect(newRequest.request.url.query.length, 'check parameters').equals(2)
pass += 1
})
Hi,
Thank you for your reply.
I resolved the issue. I needed to add 2 params to pass the test.
Thank you again for your help.
Best,
1 Like
Mmmm, marking your own post as the answer!