In Mirage JS over here, traits are demonstrated (which in data_fixture_dart are similar to those custom factory functions that redefine the default definition) as being able to be combined, which is very useful to create custom objects with varying "traits" very quickly. Also part of the Mirage JS syntax is that you can call const customStudent = server.create('student', 'withNoLastName', { firstName: 'Bob' }) to quickly create objects, built in this order:
- Create default student -> same as calling
server.create('student')
- Add in effects of
withNoLastName trait to this default student, overriding whichever fields are necessary to override to acccomplish this
- Override the object created in step 2 with firstName being
Bob
and by doing this, not only would it return you the object (not directly but in a wrapped form with functions available on the returned object), but it will persist that object in the database for later retrieval (e.g. server.db.students[0]) which is useful for later accessing inside for example tests (e.g. end-to-end tests) either directly or with DOM assertions as seen here
I was wondering if it is possible to port over something like the above features to this package, or at least some of these features. It would be very useful!
In Mirage JS over here, traits are demonstrated (which in data_fixture_dart are similar to those custom factory functions that redefine the default definition) as being able to be combined, which is very useful to create custom objects with varying "traits" very quickly. Also part of the Mirage JS syntax is that you can call
const customStudent = server.create('student', 'withNoLastName', { firstName: 'Bob' })to quickly create objects, built in this order:server.create('student')withNoLastNametrait to this default student, overriding whichever fields are necessary to override to acccomplish thisBoband by doing this, not only would it return you the object (not directly but in a wrapped form with functions available on the returned object), but it will persist that object in the database for later retrieval (e.g.
server.db.students[0]) which is useful for later accessing inside for example tests (e.g. end-to-end tests) either directly or with DOM assertions as seen hereI was wondering if it is possible to port over something like the above features to this package, or at least some of these features. It would be very useful!