Aurelia Testing Components with <compose>
I am trying to test the component of the dialog box that will be used with aurelia-dialog, which gets property bindings through a method activate(). To test the component, I configure the tests with an element <compose>that also uses the method activate()as follows:
beforeEach(() => {
component = StageComponent
.withResources('path/to/dialogComponent')
.inView(`<compose view-model="path/to/dialogComponent" model.bind="mockModel">
</compose>`)
.boundTo(mockModel);
});
However, when I come to check the view model for related properties, I get zero where the actual view model was used before.
describe('#someComponentMethod()', () => {
it('Should exist', done => {
// In the past, I succesfully accessed child viewModels for
// compose through the following property, after a general package update,
// this seems not to work anymore
let viewModel = component.viewModel.currentViewModel
expect(viewModel.someComponentMethod).toBeDefined();
// ==> Runtime error, since currentViewModel === null
done();
});
});
Is there a known or better way to test custom elements that do not have binding properties but rely on a model that needs to be bound activate()?
, : , , : Aurelia Testing Composed Custom Element
+4