Content-Type exactly equals application/json; charset=utf-8. Which Postman test snippet correctly asserts this?Option D uses pm.response.to.have.header(name, value) which checks the header name and exact value.
Option D only compares but does not assert, so test will not fail on mismatch.
Option D tries to access headers as an object, but pm.response.headers is not a plain object.
Option D checks a different value and header name case sensitivity matters in assertion methods.
X-Request-ID, regardless of its value?Option A uses pm.response.to.have.header(name) which asserts header presence.
Option A uses pm.expect(...).to.exist but pm.response.headers.get() returns null if missing, so this works but is less direct.
Option A calls has() but does not assert, so test won't fail if header missing.
Option A tries to access headers as object, which is invalid.
Server is nginx/1.18.0?pm.test('Server header matches nginx version', () => { pm.expect(pm.response.headers.get('Server')).to.match(/^nginx\/\d+\.\d+\.\d+$/); });
The regex expects three numbers separated by dots (e.g., 1.18.0), but the header is 'nginx/1.18.0' which has only two dots, so it does not match the pattern expecting three numbers.
Therefore, the test fails.
Cache-Control header contains the word no-cache. What is wrong with it?pm.test('Cache-Control contains no-cache', () => { pm.expect(pm.response.headers.get('Cache-Control')).to.include('no-cache'); });
If the header Cache-Control is missing, pm.response.headers.get() returns null.
Calling to.include on null causes a runtime error.
To fix, check header presence before asserting content or handle null safely.
Content-Type with value application/json and Cache-Control with value no-store. Which approach is best to ensure clear, maintainable tests?Option A is best because separate tests give clear, isolated results for each header.
Option A works but bundles multiple checks, making it harder to identify which header failed.
Option A is fragile and depends on string formatting.
Option A adds unnecessary complexity.