webdriverio/query-selector-shadow-dom

When no parent has been found that matches the selector the library throws an error

TomCaserta opened this issue · 2 comments

Given the following test code:

const rootComponent = createTestComponent(parent, {
    childClassName: 'boo',
})
const testSubComponent = querySelectorDeep('.hello-world .boo', rootComponent);
expect(testSubComponent).toBeNull();

The findMatchingElement will throw the error TypeError: parent.matches is not a function.

This is because it finds the test component matching .boo and traverses up to find a parent that matches .hello-world. As no element matches this selector it'l continue to traverse up until it hits the document element that has no method named matches.

Thanks for the issue and PR I'll take a look as soon as I can :)