3 ms·
Good point, I'd gotten used to that and forgotten how it is kind of counterintuitive at first. Our base test helper object does this: get root() { // It
by veidr 6y ago
Good point, I'd gotten used to that and forgotten how it is kind of counterintuitive at first. Our base test helper object does this:
get root() {
// It is important here to run cy.get()
// each time this property is accessed.
// Lots of methods of this class chain
// off of `this.root` so it needs to be
// re-evaluated every time.
return cy.get(rootComponentCss);
}
find(selector: string, options?: any) {
return this.root.find(selector, options);
}
...so that component-specific test helper objects (subclasses) can just do something like:
get sendMissileAlertButton() {
this.root.find('.x-hawaii-missile-incoming');
}
That way, it looks up the target element every time it is used in a test.
And in tests, you can just do:
tester.root.find('select.foo').select('hoge');
tester.sendMissileAlertButton.click();
EDIT: fixed code example, sorry! ;-)