-
Notifications
You must be signed in to change notification settings - Fork 44
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
SessionStorage values not honored in new Lighthouse tab #121
Comments
@olyhaa-aetna Can you try with the workaround from this issue #65 (comment)? |
Hi @MuckT! It looks like that workaround uses We already have the tokens in the We are never visiting an external url for authentication - we just store a mocked token in the |
I'll try to take a look when I'll have some spare time 😊 New job is taking a bunch of my time 😅 (and thank you for the complete issue and explanations, really appreciated 🙏🏻 ) |
As an update.... I have found a workaround by using Lighthouse's custom gatherers/audits. There's a lifecycle hook in the custom gatherer ( I'll update my repo I referenced above with the workaround and post here once that's done. Examples are usually helpful! That all being said, it would be really cool if this plugin had an option to pass in a function that could run in the new Lighthouse before visiting the URL without having to implement this fake custom gatherer / audit. I'll leave that decision up to you :) |
https://github.com/olyhaa-aetna/simple-auth-example has been updated to include the custom gatherer and audit which populates |
Oh wow, very nice workaround 🤯 . And thank you so much for providing this exampe 🙏🏻 . Would you mind if we (you or I, depending if you want to make the PR) add a link to the example to orientate people that are using session storage? Thanks for the amazing example, again 🙏🏻 |
I'm closing this issue since you've found a way to fix it. I will add a link to your repo in the documentation :) |
What does not work?
Values in
window.sessionStorage
are not copied to the new tab when the Lighthouse audit is executed.How to reproduce?
/myPage
) that requires a specific value inwindow.sessionStorage
in order to render its contentswindow.sessionStorage.setItem("my_item", "my_value")
) so that the page can be rendered properlycy.visit("/myPage")
)/myPage
(cy.lighthouse()
)For a runnable example, see https://github.com/olyhaa-aetna/simple-auth-example.
This repository has a sample app with two pages
welcomePage
- This page requires no authentication and has a login button. When the login button is clicked, a value is saved to the browser'ssessionStorage
and we are redirected to/secondPage
.secondPage
- This page requires "authentication" (a value stored insessionStorage
). If no such value is found, we will be redirected towelcomePage
.This repository has one Cypress test that will run Lighthouse on both of these two pages. Results are stored as html in
cypress/test-results
. To run the test, executenpm run cy:open
and launch the test file.Lighthouse is run for both pages, however, both the reports (found in
cypress/test-results
) are only showing results for thewelcomePage
. When the audit forsecondPage
is run, the new tab is redirected towelcomePage
since no value is found insessionStorage
. The audit is then run againswelcomePage
.Expected behavior
I want to run Lighthouse on
secondPage
.The Cypress test performs the necessary Cypress commands to "log in" the user (which will save a value to
sessionStorage
). We can see that thesecondPage
is rendered properly in the original tab of Cypress viewer. When the new tab is opened to perform the Lighthouse audit, I want to see thissecondPage
visible, and I want the Lighthouse report to reflect thissecondPage
URL.Instead, when the new tab is opened, we see the
welcomePage
.Environment:
Any other information that may help fixing the issue?
Two possible solutions (although I'm not sure how feasible they are):
sessionStorage
from the existing tab to the new tab.The text was updated successfully, but these errors were encountered: