lundi 28 septembre 2020

Ember + Mirage: response mock errors

  // 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/new?email=test@email.com');
  });

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




Aucun commentaire:

Enregistrer un commentaire