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`{{my-component}}`);
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()?
If you are registering a test helper and calling it
pushMirageRecordsToStorethen it should be available as a global so you should be able to access it in your tests aspushMirageRecordsToStore();, notthis.pushMirageRecordsToStore();.There's good documentation on registering test helpers in the ember docs here.
p.s. just to confirm, the helper you shared in the link was called
pushMirageDbIntoStorebut here you callpushMirageRecordsToStore. The name will need to be identical :-)