Skip to content
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

Integration tests: wait until stories appear #3027

Merged
merged 1 commit into from
Feb 19, 2018

Conversation

Hypnosphi
Copy link
Member

Issue: Integration test are failing randomly

What I did

Used page.waitFor API to ensure that stories are rendered before taking screenshot

@tmeasday maybe we can use a similar approach on chromatic?

@Hypnosphi Hypnosphi added the maintenance User-facing maintenance tasks label Feb 19, 2018
@Hypnosphi Hypnosphi merged commit 7e026e3 into master Feb 19, 2018
@Hypnosphi Hypnosphi deleted the intagration-wait-stories branch February 19, 2018 21:02
@tmeasday
Copy link
Member

@Hypnoshi maybe we need an async story API ;)

@Hypnosphi
Copy link
Member Author

How would it help in terms of screenshoting?

@tmeasday
Copy link
Member

You could do the waiting inside the story and then the screenshotting lib could just render the story (including waiting) and then immediately take the SS, without needing any special logic.

@Hypnosphi
Copy link
Member Author

Hypnosphi commented Feb 19, 2018

How would browser/node interop be implemented in that scheme? Would it involve some globals pollution?

@tmeasday
Copy link
Member

I'm not sure what you mean? Are you thinking of storyshots?

@Hypnosphi
Copy link
Member Author

Hypnosphi commented Feb 19, 2018

do the waiting inside the story

Actually, I don't really get this part. The only thing we're waiting for are the stories themselves. So if they waited for something else, it wouldn't make things better

@Hypnosphi
Copy link
Member Author

Are you thinking of storyshots

No, I'm thinking of puppeteer

@tmeasday
Copy link
Member

@Hypnosphi ok, sorry this was a bit of a flippant comment, what I mean is something like:

.add('async story', async () => {
  return new Promise(resolve => {
    const story = <X ref={element => element.getElementByTagname('iframe')[0].onload = resolve(story) }});
  });
}

The above story will only "finish" when the iframe has loaded, and thus the library can just do something like:

await story();
takeScreenshot();

@tmeasday
Copy link
Member

I'll admit I haven't really thought through the mechanics of how the above would work.

@Hypnosphi
Copy link
Member Author

await story();
takeScreenshot();

In which environment does this code run?

@tmeasday
Copy link
Member

Inside a browser. If you are controlling it via puppeteer there might be an additional layer of indirection like:

Page.evaluate(async () => await story());
Page.captureScreenshot()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants