Recall & Review
beginner
What is a JSON value assertion in Postman?
It is a check in Postman tests that verifies if a specific value in the JSON response matches the expected value.
Click to reveal answer
beginner
How do you access a JSON value in Postman test scripts?
Use `pm.response.json()` to parse the response, then access values like `jsonData.key` or `jsonData['key']`.
Click to reveal answer
beginner
Example of a simple JSON value assertion in Postman?
```javascript
const jsonData = pm.response.json();
pm.test('Check user name', () => {
pm.expect(jsonData.name).to.eql('John');
});
``` This checks if the 'name' value is 'John'.Click to reveal answer
beginner
What happens if a JSON value assertion fails in Postman?
The test will show as failed in the Postman test results, helping you identify issues in the API response.
Click to reveal answer
beginner
Why use JSON value assertions in API testing?
To ensure the API returns correct and expected data, improving reliability and catching errors early.
Click to reveal answer
Which Postman method parses the JSON response body?
✗ Incorrect
pm.response.json() parses the response body as JSON so you can access its values.
How do you assert that a JSON key 'status' equals 'success' in Postman?
✗ Incorrect
Use to.eql('success') to check exact value equality.
What does a failed JSON value assertion indicate?
✗ Incorrect
A failed assertion means the actual value differs from what was expected.
Which of these is a best practice for JSON value assertions?
✗ Incorrect
Checking only necessary keys keeps tests focused and efficient.
In Postman, where do you write JSON value assertions?
✗ Incorrect
The Tests tab is where you write scripts to check response values.
Explain how to write a JSON value assertion in Postman to check if a response key 'age' equals 30.
Think about parsing JSON and using pm.expect to compare values.
You got /4 concepts.
Describe what happens when a JSON value assertion fails during a Postman test run.
Consider how Postman shows test results.
You got /3 concepts.