Closed manuel-guilbault closed 5 years ago
There is now :)
Awesome :)
@manuel-guilbault Can you describe to us what you would like to be able to do in such a test?
Here's the features I would need:
activate
methodHere's a typical test case I would write:
import {StageRoute} from 'aurelia-testing';
import {bootstrap} from 'aurelia-bootstrap';
describe('the list component', () => {
let component;
beforeEach(() => {
component = StageRoute.component('list')
.withResources('custom-element-needed-by-list')
.withRouteParams({ /* Some route parameters passed to activate */ })
.bootstrap(aurelia => {
aurelia.use.standardConfiguration();
//Here I would register an HttpClient mock or something similar in the DI container
});
});
afterEach(() => {
component.dispose();
});
it('should load data upon activation', done => {
component.create(bootstrap)
.then(() => {
let elements = document.querySelectorAll('.container .item');
// Here I would assert that the items were properly rendered
})
.then(done);
});
});
What the latest on this issue? We can't seem to find a way to call activate in our tests.
Edit: Oops, I found how to do it. component.viewModel.activate()
@EisenbergEffect can be closed?
I've tried to roll our own abstractions here to test routed components but ran into the same issue describe above
(the router's _findViewModel method returns undefined)
At the moment, is there a way to test a routed component? I tried the following:
This throws an error because no viewModel is set on the container (the router's _findViewModel method returns
undefined
).As far as I can tell, the only way to test a routed component is with end-to-end tests right now. Is there any plan to support this kind of feature?