Day 10 - Assertion error

Hi,
I have converted the response to text and I am trying to check if it includes the path and value in the response.

When I submit the collection I get an assertion error -

1 Like

The response from that API is in JSON format.

The document doesn’t explicitly tell you this, but its expecting you to parse the response as JSON, and then target the relevant element directly.

You are targeting the element using pm.response.text() and the includes assertion, which isn’t the best assertion for this type of test. All you are testing is that “value” exists somewhere in the response. Parse the response to json() and use “to.eql” instead and target the element specifically in the response.

1 Like

Thank you for submitting your post.
I will jump in the last paragraph of @michaelderekjones and give a solution.

The parameter testData reference the property value in the data file
From my part , I parse the response to json() and use “to.be.eql” to target “post” in the response. I reuse that in the next line to check the property value in the data file.

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

@jecorde

The assertions in that screenshot are not checking the response.

They are targeting the data file.

1 Like