Skip to content

Request to add multiple factory "traits" simultaneously and have object creation similar to Mirage JS #2

Description

@aashir-khan

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:

  1. Create default student -> same as calling server.create('student')
  2. Add in effects of withNoLastName trait to this default student, overriding whichever fields are necessary to override to acccomplish this
  3. 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions