-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 'waitUntil' option to puppeteer of storyshots #3156
Conversation
If some elements use additional xhr requests (like async image loading). Puppeteer might not imprint the end state of the page. Puppeteer has built-in method to resolve this - https://github.com/GoogleChrome/puppeteer/blob/c857aef5893042ac2f8b587283683396ae9c333b/docs/api.md#pagegotourl-options This option is fairly general so it should be okay to use for other cases as well. However, 'beforeScreenshot' could be used instead, but proposed approach seems more definite and reliable As additional further improvement, these `goto` options might be exposed to consumber as well
Codecov Report
@@ Coverage Diff @@
## master #3156 +/- ##
=======================================
Coverage 35.98% 35.98%
=======================================
Files 437 437
Lines 9474 9474
Branches 899 885 -14
=======================================
Hits 3409 3409
+ Misses 5506 5493 -13
- Partials 559 572 +13
Continue to review full report at Codecov.
|
Will it work on examples that do some kind of polling? |
If a user decides to poll every
That is probaly super uncommon... If a story is about a component that changes over time.. My advice is to create a story for a few moment in time, not to do the actual polling in storybook. What do you think @Hypnosphi ? |
Ok, at TeamCity we have some stories that poll data from actual server, but we use a period larger that 500ms, so it's OK But we may start using websockets for that at some point. Would WS connection count as "network connection"? UPD: Anyway, screenshot testing isn't applicable to such stories |
Good question. I think even with old-school comet technics and the new ones like ws it should work in the same way (should be tested, to verify of course). In the case, when ws, on user agent side, isn't always receiving new data and if there is no ongoing ping pong frames (https://html.spec.whatwg.org/multipage/web-sockets.html#ping-and-pong-frames) proposed logic should work. Since of course while test run in in progress, you probably would want, at some point, to stop receiving new data during the screenshot time. And in both ws and comet technics (known to me), you can adjust the heart-beat rate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
If some elements use additional xhr requests (like async image loading).
Puppeteer might not imprint the end state of the page. Puppeteer has
built-in method to resolve this -
https://github.com/GoogleChrome/puppeteer/blob/v1.1.1/docs/api.md#pagegotourl-options
This option is fairly general so it should be okay to use for other cases
as well.
However, 'beforeScreenshot' could be used instead, but proposed approach seems
more definite and reliable
As additional further improvement, these
goto
options might be exposed toconsumber as well