wix-incubator / unidriver

UniDriver - Universal Component Drivers 🚀
MIT License
53 stars 15 forks source link

`@unidriver/jsdom-react` - Improve stack trace for `NoElementWithLocatorError` thrown from `$` #152

Open kobiburnley opened 3 years ago

kobiburnley commented 3 years ago

Improve stack trace for error "Cannot find element with locator"

Before

● Test suite failed to run

Error: Cannot find element with locator: [data-hook="collection-tablex"]

at getElement (../../../../node_modules/@unidriver/jsdom-react/src/index.ts:145:12)

After


Error: Cannot find element with locator: [xdata-hook="collection-table"]

    at getElement (/Users/kobia/IdeaProjects/cairo/node_modules/@unidriver/jsdom-react/src/index.ts:145:12)
    at elem (/Users/kobia/IdeaProjects/cairo/node_modules/@unidriver/jsdom-react/src/index.ts:113:21)
    at exports.jsdomReactUniDriverList.parent (/Users/kobia/IdeaProjects/cairo/node_modules/@unidriver/jsdom-react/src/index.ts:154:14)
    at elem (/Users/kobia/IdeaProjects/cairo/node_modules/@unidriver/jsdom-react/src/index.ts:26:20)
    at elem (/Users/kobia/IdeaProjects/cairo/node_modules/@unidriver/jsdom-react/src/index.ts:113:21)
    at exports.jsdomReactUniDriverList.parent (/Users/kobia/IdeaProjects/cairo/node_modules/@unidriver/jsdom-react/src/index.ts:154:14)
    at elem (/Users/kobia/IdeaProjects/cairo/node_modules/@unidriver/jsdom-react/src/index.ts:26:20)
    at elem (/Users/kobia/IdeaProjects/cairo/node_modules/@unidriver/jsdom-react/src/index.ts:113:21)
    at getElement (/Users/kobia/IdeaProjects/cairo/node_modules/@unidriver/jsdom-react/src/index.ts:142:23)
    at elem (/Users/kobia/IdeaProjects/cairo/node_modules/@unidriver/jsdom-react/src/index.ts:113:21)
    at Object.click (/Users/kobia/IdeaProjects/cairo/node_modules/@unidriver/jsdom-react/src/index.ts:163:15)
    at Object.<anonymous> (/Users/kobia/IdeaProjects/cairo/packages/cairo/src/__tests__/components/InfiniteScrollTable/InfiniteScrollTable.bulkSelect.spec.tsx:38:7)
GabiGrin commented 3 years ago

@kobiburnley nice, thanks! ✨ @Tokyros fyi

GabiGrin commented 3 years ago

@kobiburnley what did the commits after do? what didn't work?

kobiburnley commented 3 years ago

@kobiburnley what did the commits after do? what didn't work?

Changed strategy, instead of creating the error at the top of $ function, added await on the containerFn() call.

Rest of the commits are formatting issues

GabiGrin commented 3 years ago

@kobiburnley cool thanks! So are we ok to merge and publish?