Fixtures are another way of mocking data. It's static data that can be used in our model to display to the user when testing our application. In this recipe, we'll see some basics on how to set it up with Ember CLI Mirage.
As with many of our other examples, we'll be using Ember CLI Mirage. Instead of using a factory, we'll set up fixture data.
Begin by creating a new application. Then add the Ember CLI Mirage add-on and generate the model and routes for the application:
$ ember install ember-cli-mirage $ ember g model student name:string age:number $ ember g route index $ ember g adapter application $ ember g fixture students
These commands will generate the basic structure of our app. In this application, fixture data will be used to display student information. For the sake of simplicity, we'll only be displaying this information and not manipulating it.
In the
mirage
fixtures
folder, update thestudents.js
file and add the fixture data:// app/mirage/fixtures...