Only One test Fail I don't know Why

Please help me my one test fails I don’t know why.
snapshot attached for reference.

Kindly helps me thanks in advance.

Hi Muhammad,

I haven’t completed the Student Expert training yet, so this is partly a guess, but hopefully it will help you :slight_smile:

The test that’s failing is called “Used variables”. If you select the Tests tab of the request, and find the piece of Javascript which contains “Used variables” (line 61), this is the code which is identifying the failure.

The assertion that’s failing says “expected -1 to be above -1”; note that there is only one assertion in that test which is checking for a value above -1, and that is:

//auth should also use var
pm.expect(encodeURI(authObj.apikey.value).indexOf('%7B%7B')).to.be.above(-1);

If you would like a bigger hint, I will hide it behind the spoiler tag below, however it’s worth trying to solve the puzzle just with the above code, because quite often in the real-world you’ll have to try to figure out why a test has failed when maybe somebody else wrote it!

Further hint: %7B%7B is the URL-encoded version of the characters {{. This test is checking the Authorization for the request, and checking to see whether it’s using a variable. I’m presuming that in one of the tests, it must have requested that you set the authorization using an API key which is set in a variable; if it cannot find {{ in the API key value, then this indicates that you have not used a variable to insert your API key (maybe you hardcoded the value instead).