ember-component-inbound-actions
ember-component-inbound-actions copied to clipboard
"Asynchronous side-effects" from component unit tests
I'm writing a unit test around a component that uses InboundActions
and getting the following error:
Assertion Failed: You have turned on testing mode, which disabled the run-loop's autorun. You will need to wrap any code with asynchronous side-effects in a run
To isolate this to InboundActions
, I've eliminated all code in the component. At this point here are the files:
// app/components/bogus-component/component.js
import Component from '@ember/component';
import InboundActions from 'ember-component-inbound-actions/inbound-actions';
export default Component.extend(InboundActions, { });
// tests/unit/component/bogus-component/component-test.js
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
module('Unit | Component | bogus-component', function(hooks) {
setupTest(hooks);
test('unfiltered', function(assert) {
this.owner.factoryFor('component:bogus-component').create({});
assert.ok(true);
});
});
Version deets:
"ember-cli": "~3.2.0",
"ember-component-inbound-actions": "^1.3.0",
Let me know if you need anything else.
Follow up: is the fix just wrapping the this.owner.factoryFor(...)
in an async/await/run
, like this?
// tests/unit/component/bogus-component/component-test.js
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { run } from '@ember/runloop';
module('Unit | Component | bogus-component', function(hooks) {
setupTest(hooks);
test('unfiltered', async function(assert) {
await run(() => this.owner.factoryFor('component:bogus-component').create({}));
assert.ok(true);
});
});