Mirage Models

Here, you’ll learn how to create and use mirage models in an Ember.js application.

We'll cover the following

Creating mirage models

Mirage needs to know what types of mock data we want, so we have to tell it by creating mirage models. Unsurprisingly, there’s a blueprint for that:

ember g mirage-model band

When we look at the generated file, we see a strange syntax to define the class. However, it’s only strange if you haven’t worked on Ember apps in the pre-Octane times. It uses Model.extend({...}) instead of the ES6 class syntax. It’s useful to know that Ember had its own class system that originated when there wasn’t widespread browser support for ES6 classes or transpilers for that matter. Being aware of this helps us read the code of not entirely Octane Ember apps or add-ons. This older syntax is mostly referred to as “classic” Ember class syntax.

Get hands-on with 1200+ tech skills courses.