I am trying to test a custom dialog component to be used with aurelia-dialog
which gets it's property bindings through an activate()
method. In order to test the component, I am setting up the tests with a <compose>
element which also utilizes the activate()
method like so:
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 test the view-model for bound properties I get a null where the actual view model used to be.
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 which have no bindable properties but rely on a model to be bound by activate()
?
Additionally, in order to test rendering: There seems to be a similair issue that might be related: Aurelia Testing Composed Custom Element