Hello,
When I send the following request https://api.getpostman.com/collections/12958258-0717e57e-83a9-4634-81c4-f24e1f93927f
Two of the test cases are failing. And I unsure what the problem is.
Thanks in advance
Hello,
When I send the following request https://api.getpostman.com/collections/12958258-0717e57e-83a9-4634-81c4-f24e1f93927f
Two of the test cases are failing. And I unsure what the problem is.
Thanks in advance
Good Day @danpaul,
I would love to assist you, I just need additional reproduction steps. What part of the challenge are you on, can you provide some additional details like:
That will help all of us better understand what is happening and assist you. Hopefully we can get those tests passing, if you haven’t figured it out already.
– Raye
Hello,
The part of the challenge I am running is Day: 02 Collections and environments. I have included the test cases I am running below:
// counter for passed tests
let pass = 0
let totalToPass = 5
let collection = pm.response.json().collection
pm.test(“If you have any failures, review the failed test results or ask for support in the community forum. Remember to save your changes if you update the collection. When all of your tests pass, you are done with today’s challenge.”, () => {
pm.expect(true);
pass += 1
});
pm.test(“Status code is 200”, () => {
pm.response.to.have.status(200);
pass += 1
});
pm.test(“Correct collection returned”, () => {
pm.expect(collection.info.name).equals("Day 02: Collections and environments")
pass += 1
})
let folder = collection.item.find(fol => {return fol.name === “Collections and environments”})
pm.test(“Old request updated”, () => {
let oldRequest = folder.item.find(req => {return req.name === "POST raw text"})
pm.expect(oldRequest.name, 'check name').equals("POST raw text")
pm.expect(oldRequest.request.method, 'check method').equals("POST")
pass += 1
})
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
})
// visualization for test results
let template
if (pass == totalToPass) {
template = `🍪 passing!
<br />
<img src="https://media1.giphy.com/media/Rznz8HjrKQAOQ/giphy.gif?cid=ecf05e47eb8e64j0aasd8oot8tck9rg49vhqqzxee75hwzq1&rid=giphy.gif&ct=g" />
`
} else {
template = `đź™… please try again
<br />
<img src="https://media2.giphy.com/media/mlvseq9yvZhba/giphy.gif?cid=ecf05e471upg7bl8bd0stb0p3jmazll50q1ctfg2ljwl4ks3&rid=giphy.gif&ct=g" />
`
}
pm.visualizer.set(template)
I have a environment set up based on the documentation. And that goes for my Postman settings.
Thanks in advance
Hi @danpaul
Are you able to confirm that your collection, folder and requests are named exactly as below (including matching case)? The script expects to find them named exactly as such, and it will be unable to progress with identifying them if the name is different.
Hello,
Please see the enclosed for how I have named the folder and the requests.
Thanks
Hi @danpaul you will need to rename the requests so that they match mine - e.g. the word “POST” and “GET” need to be also part of the request name. (This is something you will need to do carefully on every day - as you have encountered, the tests will fail to run correctly if the requests aren’t named exactly as the challenge specified)
Hello @neilstudd, I have renamed my requests and the test cases are now passing. Thanks for your help with this.
I ran into the same issue. The console helped me locate my error.