In documentation it shows how to use server global to create models and everything, but it is possible to use scenarios to populate the mock database? Or are we supposed to create objects on the fly?
The "default scenario" is really meant to be a place to seed the database during development, as each test is really its own scenario.
If you wanted to share some common seed logic across all tests, you could export a function and share that, calling it either in beforeEach
within a test module, or even the moduleForAcceptance
helper so it runs every time.
You might even be able to make a new file under /scenarios
just to keep things organized (I'm not 100% on this due to the way modules are read in). It doesn't really matter where you put it, though.
Untested, but something like the following:
// mirage/scenarios/tests.js
export default function(server) {
// generic test setup
}
// tests/helpers/module-for-acceptance.js
import 'testSetup' from 'mirage/scenarios/tests';
...
testSetup(server)