I am having difficulty unit testing a select element bound to an asynchronous method.
No matter what i do, i get Timeout - Async callback was not invoked… by jasmine
The code:
public units = [];
setTimeout(() => {
this.units = ["per Hour", "per Annum", "per Day"]
}, 100);
The test:
it("please work", (done) => {
component.create(bootstrap).then(() => {
component.waitForElement(`select[name="units"]`, {}).then((element: HTMLSelectElement) => {
expect(element.options.length).toBe(4);
done();
});
});
});
I can convert this to a static method and the test works. I’ve tried set timeouts, in the waitForElement options, at various entries before the expectation.