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

Simplify setup in happoPlaywright.init #9

Merged
merged 3 commits into from
Dec 18, 2024
Merged

Simplify setup in happoPlaywright.init #9

merged 3 commits into from
Dec 18, 2024

Conversation

trotzig
Copy link
Contributor

@trotzig trotzig commented Dec 18, 2024

By lazy-loading the takeDOMSnapshot function, we can remove the need to pass in a page or context in beforeAll.

This function is deprecated and unused. We can delete the code here to
reduce complexity.
While debugging things for a customer, we found that `beforeAll` doesn't
give us a context that we can use. While running the local tests, I
found that I could initialize the takeDOMSnapshot function lazily when
needed. This will simplify setup for users of this library.

I'm making this a "soft" breaking change by generating a warning log if
you pass a context to happoPlaywright.init. This way people can discover
the simplification without much disruption.
So that we have some test coverage in this repo.
@trotzig trotzig merged commit 5f30825 into main Dec 18, 2024
1 check passed
@trotzig trotzig deleted the before-all branch December 18, 2024 11:59
await contextOrPage.addInitScript({ path: pathToBrowserBuild });
await contextOrPage.addInitScript(`
window.addEventListener('load', () => {
window.happoTakeDOMSnapshot.init(window);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if we still needed to call this init function somewhere, but I found the function definition and discovered that it is now a noop, so removing this should be fine https://github.com/happo/happo-e2e/blob/5903e00c9dd2bb4d5a9cf9c2994181668ddfc634/takeDOMSnapshot.js#L347-L351

However, if it is possible for someone to have an updated version of happo-playwright but an old version of happo-e2e, they may run into a confusing situation. I'm not entirely sure what that experience would be like, but if we think it is likely that someone will run into this, then maybe we should make an adjustment to help them out.

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

Successfully merging this pull request may close these issues.

2 participants