// Some code from router
return user.save().catch(e => {
debugger; // says: ErrorClass {isAdapterError: true, stack: "Error: The adapter rejected the commit because it was invalid}
});
// Test
import { Response } from 'miragejs';
test('Show error page when failed uniqueness validation', async function(assert) {
server.post('/users', () => {
return new Response(422, {}, { errors: [{ detail: 'has already been taken' }] });
});
await visit('/users/[email protected]');
});
I'm using Ember 3.16
and ember-cli-mirage 1.1.8
. I have a test which is not working properly. I'm mocking a 422 Response from mirage. This response also contains some errors. In the router, where the request is made, the request fails (enters the catch
) but when I inspect the error it doesn't tell me the status code or the details of it
looking at the documentation from emberCLI Mirage V1.1.8, it shows this example to test errors
it's a different syntax to specify the error and the status response