I'm writing unit and integration tests against an Ember.js application, and I can't connect to the server when the application is under test. This means I need to use DS.FixtureAdapter to back up my data store.
But I'm not personally a fan of fixtures in large applications, because it's so hard to come up with a single set of fixtures that work with every test case. I prefer tools like factory_girl and machinist that allow me to generate test-specific data that's isolated from all other tests:
FactoryGirl.define do
factory :user do
name 'John Doe'
date_of_birth { 21.years.ago }
end
end
# In specific test cases:
user = FactoryGirl.build(:user)
young_user = FactoryGirl.create(:user, date_of_birth: 17.years.ago)
Of course, factory_girl and machinist can also generate related models automatically.
Is there any easy way to do this in Ember.js right now? Are there techniques, conventions or libraries which might make this easier? Googling does not real any options yet.
I created a project called Ember Data Factory Guy recently to help create fixture data for ember projects that use ember-data. It works with REST or ActiveModel adapter and has test helpers to make using it pretty easy.
Check it out here:
https://github.com/danielspaniel/ember-data-factory-guy
It supports belongsTo, hasMany ( even polymorphic ) associations .. sequences, embedded belongsTo .. and a few other things.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With