Spot the incorrect HTTP status code assertion when testing a resource creation endpoint.
Codejavascript
// Test: creating a new user via POST
const res = await fetch('https://api.example.com/users', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name: 'Ada' })
});
// The API returns the newly created resource
const body = await res.json();
// Assertion
if (res.status !== 200) {
throw new Error('User was not created: ' + res.status);
}
console.log('Created user id:', body.id);