Day 3: "Script added" test fails

I am getting this error:
Script added | AssertionError: check script: expected ‘\r,\r,’ to include ‘console.log’
I have three console.log() statements in the Scripts part of the request. What could be the reason for this error?

Hi @docking-module-arch3 . Welcome to the Postman Community!

Can you share screenshots of your scripts tab and the error?

Hi Gbadebo Bello, I attached the screenshots. Thank you for your help.

The error message “AssertionError: check script: expected ‘\r,\r,’ to include ‘console.log’” signals a discrepancy between expected and actual script content.
The anticipated behavior entails console.log statements within a particular code segment, potentially separated by two carriage returns (\r,\r). Several factors could trigger this error.
Firstly, while the script may contain console.log statements, they might not execute due to conditional logic or misplaced placement within the code. Secondly, differing newline characters, such as \n or a combination of \r and \n, could cause the check to fail. Moreover, unexpected characters or formatting issues within the script might also be culprits. To address this, it’s crucial to confirm the console.log statements’ placement within the script and adjust newline characters if necessary.
Additionally, eliminating extraneous characters or formatting anomalies is essential. Employing code for matters or linters and consulting platform documentation for script requirements can aid in troubleshooting. By meticulously examining the script and adhering to these steps, pinpointing the error’s root cause becomes feasible, ensuring console.log statements function correctly within the intended context.

1 Like

What do you have in the Pre-request?

What’s the usage of everything past line 2 on the Post-response - I don’t think you need any of that in there.

You only need a single log in there and having more on different lines is likely causing the issue here and it’s picking up the carriage returns between line 2 and line 4.

I have nothing in the Pre-request. And assignment says to add more log statements.

There isn’t a requirement to add more, it says feel free to add more but you don’t need to :smiley:

Can you share the URL of your public workspace please?

Actually I also tried it removing other log statements but I still get the same error.

You have empty lines here, those can be deleted. This is the reason for me asking what you had in the Pre-request:

You can remove everything under line 2:

Save those changes and give that a go.

I did what you say but still get the same error.

I believe I have figured this out and It might be down to the changes we have made to scripts.

Can you add console.log() to line 1 of the Pre-request section on the Rick and Morty request?

Yes, it worked now. Thank you!

I think the requirement needs to be clarified. Thanks for the help!

The requirement (a few tweaks to the names aside) is fine.

The changes to the Scripts, caused an unintentional change which now looks for that value in the pre-request rather that the post-response now.

I will be making a lot of changes to align everything.

1 Like