samedi 14 juillet 2018

How to load custom test helpers in Ember 3.2 tests?

I seem to be missing some info about how to register a test helper in Ember 3.2, looking for some guidance:

I'm trying to use a test helper (see here) which I've placed in my tests/helpers directory, and am trying to reference it in a test:

import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';

module('Integration | Component | my-component', function(hooks) {
  setupRenderingTest(hooks);
  setupMirage(hooks);

  test('it renders nothing by default', async function(assert) {
    const company = server.create('company');
    this.pushMirageRecordsToStore(); // this doesn't work
    await render(hbs``);

    assert.equal(this.element.textContent.trim(), '');

  });

When this.pushMirageRecordsToStore() is called the error is:

TypeError: this.pushMirageRecordsToStore is not a function

Which leads me to believe the registerAsyncHelper helper in that link is not being called.

My question is how do I make the Ember test framework call registerAsyncHelper in that test helper so I can do this.pushMirageRecordsToStore()?




Aucun commentaire:

Enregistrer un commentaire