Playwright · Junior · Question 61 of 75
What does this API test check?
const res = await request.get("/api/users/1");
expect(res.ok()).toBeTruthy();
expect(await res.json()).toMatchObject({ id: 1 });- 1The request takes less than one second to answer
- 2The user page renders in the browser correctly
- 3Status is 2xx and the body contains
id: 1
Show the answer
Correct answer: Status is 2xx and the body contains id: 1
Explanation
ok() is true for 200-299 responses. toMatchObject checks a subset of fields, ignoring others.