Skip to content

v2.11.5

Compare
Choose a tag to compare
@danielspaniel danielspaniel released this 02 Feb 10:23
· 459 commits to master since this release
  • added better error message when forgetting to needs a transform in a unit test #273

Commonly in a unit test you will forget to needs everything you "need" like transforms

import {mockFindAll, mockSetup, mockTeardown, manualSetup} from 'ember-data-factory-guy';
import {moduleFor, test} from 'ember-qunit';

moduleFor('route:profiles', 'Unit | forgetting to needs transform', {
  beforeEach() {
    manualSetup(this.container);
  },

  afterEach() {
    mockTeardown();
  },

  needs: [
    'model:profile',
//    'transform:just-a-string'  ( it's common to forget this needs ) 
//                               ( but the profile model uses this transform )   
  ]
});

test('profiles', function(assert) {
  // this will barf because you forgot to needs a particular transform (just-a-string) 
  // that the profile model needs, but now with this version of FactoryGuy you will 
  // get a friendly message repeating pretty much what I just said in this comment
   mockFindAll('profile', 2)  })