reg-viz / storycap

A Storybook Addon, Save the screenshot image of your stories :camera: via puppeteer.
https://www.npmjs.com/package/storycap
MIT License
701 stars 89 forks source link

Error: failed to find element matching selector inside CapturingBrowser.resetIfTouched() #806

Closed stefanroeck closed 12 months ago

stefanroeck commented 1 year ago

The problem as described in #712 still happens. Looking at the source code, the root cause seems to be that the story is re-rendered before the cleanup events are fired. A fix locally working for me is to move down the line

this.setCurrentStory(story, { forceRerender: true })

after the cleanup events are fired.

If you agree I can prepare a PR.

Stacktrace of the error:

Error: Error: failed to find element matching selector "[data-testid='single-row-actions-button']"
    at ElementHandle.$eval (\visreg-test\node_modules\puppeteer-core\lib\cjs\puppeteer\common\JSHandle.js:649:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async CapturingBrowser.resetIfTouched (\visreg-test\node_modules\storycap\lib\node\capturing-browser.js:89:13)
    at async CapturingBrowser.screenshot (\visreg-test\node_modules\storycap\lib\node\capturing-browser.js:359:13)
    at async time (\visreg-test\node_modules\storycrawler\lib\timer.js:14:20)
    at async \visreg-test\node_modules\storycap\lib\node\screenshot-service.js:27:39
    at async \visreg-test\node_modules\storycrawler\lib\async-utils.js:153:28
stefanroeck commented 12 months ago

@Quramy thanks for merging, I'm closing this ticket now. Do you have an ETA for a release already?