Intro to Postman course - Error in test

I’m learning postman for school and just have to get right exactly what this video tells me to. I’m trying to follow it TO THE LETTER, because I don’t want mistakes, pretty much every time I make one it stops my progress. I really don’t have much interest in the program other than finishing my schoolwork I need to do with it. I’m just learning right now Anyway here is the video.

I am at 16:53
I have tried searching don’t see this particular problem with replaceall, you can see in the video I’m not supposed to get this result, I’ve checked the syntax several times, it I don’t see any differences, Also it appears I created several repositories on github fiddling with it and try to get the right results, which I’ll need to delete

I hope you can see the image below, I only see code but hopefully that will become an image (or you’ll be able to download it) when I post this, it’s the errors I am getting

Hey @needtolearnpostmanfo :wave:

Welcome to the Postman Community! :postman:

I have a couple of questions based on the things I cannot see from your images:

  • What is the value of repositoryName and when did you set that as a Collection variable?
  • What does the response body look like and what is the value of jsonData.name?

I would highly recommend using the Postman Console and making it your best friend what trying to debug anything in the scripts.

Log out the values that you’re using in that test to see what is actually returned for them:

console.log(pm.collectionVariables.get('repositoryName'));
console.log(pm.response.json().name);

The replaceAll() function is not working as the data point it’s trying to change, isn’t defined and it can’t perform that action.

I am really confused now as I’m not quite familiar with those terms, basically this is what I am supposed to get as the response when I click the send button at 16:54 and you can see that is not what I am getting with the image I posted in my first video

If you could just maybe guide me as to what you need for other information as I don’t quite understand where to get it basically I just followed exactly what the video says and must have made a mistake along the way

What is the value of repositoryName and when did you set that as a Collection variable?

Where can I get this information?

What does the response body look like and what is the value of jsonData.name?

I’m not quite sure what you mean by response body, unless you mean the image I posted above where it doesn’t match the video at 16:54, UNLESS maybe you mean the body tab under the request, here is that

bodytab

Log out the values that you’re using in that test to see what is actually returned for them:

console.log(pm.collectionVariables.get('repositoryName'));
console.log(pm.response.json().name);

What do you mean “log them out?” Yes, I don’t know much about postman it’s required as part of my school work to work somewhat with it.

The replaceAll() function is not working as the data point it’s trying to change, isn’t defined and it can’t perform that action.

Then, why did they get the response at 16:54 in the video without the extra bit I am getting, that’s what I’m supposed to get.

I can see that it’s a request to create a new repository on Github. I assume that you have added the correct auth method to the request as it’s returning a 201 status code.

The test that is failing, is asserting that the repository name that you have previously added to a Collection Variable (Maybe in the pre-request script) and checking this against the response that is returned from Github.

The replaceAll part of the test is most likely due to Github adding - to repo names, if they contain spaces. Without the the values from the response and the Collection variable wouldn’t match and would fail the test.

In either the pre-request or test scripts, you have the ability to log data from either the request or the response out to the Postman Console (You can find this option in the bottom menu bar)

You can use this to console log those values from the test to see what those are:

console.log(pm.collectionVariables.get('repositoryName'));
console.log(pm.response.json().name);

Yes, I have, it appears, created several repositories, by submitting the request several times, that I don’t need. I just wonder which ones I do need to delete. Here is a list of them on Github, as you can see.

All of them, except the one below the one I am hovering my mouse over were updated 2 days ago, but they don’t have the times they were created, which would really help.

You mean input that snippet of code somewhere into postman to see what shows up in the console log? Where would I put it?

Add that to the Tests tab, if you added both of them to the pre-request tab one of them would fail. The variable would be logged to the Postman Console but the line that is logging pm.response.json().name would errot as the rest hasn’t been execute at that point.


As for the repos, each time you make a request it’s going to create a new one, that failing test has nothing to do with that. If the structure of the request is correct and what the Github server is expecting, it’s going to create it.


I honestly think that you would benefit from taking and completing some of the internal Postman training course that we have to get a better understanding of the Postman platform. I feel you have jumped into a more advanced training course without first gaining a basic understanding of the tool.

Yes, I’ll do so, I do feel this is quite over my head, but it IS part of what I have to for my school assignment, in particular, this is course I am taking

I wouldn’t be taking this part if I didn’t have to, here are the parts that deal with postman

Here’s the sections

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