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
Percy Visual Regression fails with timeouts when initializeWorker is called #55
Comments
@wwilsman @Robdel12 Tagging you since I see you are the most active in Sorry if I tagged the wrong Percy team members here, I just pretend to give some visibility to the issue. I'm not sure if it's more related to |
Also having this issue. My guess is that this is a Percy issue. Guessing that Percy doesn't support service workers? |
👋🏼 It's likely causing issues with asset discovery. Percy's SDK needs to request the assets to save them. Can you share debug logs? https://docs.percy.io/docs/debugging-sdks#debug-vs-verbose-logging My guess is asset discovery can't request/save assets because they're being mocked or blocked. |
Thanks @Robdel12 - I just started working with Percy today. I will look for logs and share them. |
@Robdel12 here is the output of running percy with storybook in debug mode. There are a number of types of errors. I am not sure which are the relevant ones. The process for obtaining this output is:
msw provides mocked data and images which are then used in the stories. EDIT: btw, this is a React component library, which uses the MS Fluent UI component library. |
My tests hang with the official puppeteer storyshots addon, Storybook itself works fine when I run it, but it times out when I run the tests. |
I think I'm experiencing the same error. When starting Storybook in local with When putting Percy in the middle is when MSW does not play well with Storybook apparently. Steps to reproduce it:
Dependencies
|
One possible workaround could be using the http-middleware module. Run the same mocks using a node server instead of a service worker when running Percy tests: https://github.com/mswjs/http-middleware |
Likely what will need to happen. Since this is a network interception library, it looks like it's doing its job by intercepting network requests. Percy also watches requests being made in the browser to capture them, so it sounds like this library is preventing that from happening (https://docs.percy.io/docs/debugging-sdks#how-sdks-work) |
I'm going to take a look into this. Thanks for sharing @jefffohl.
Thanks @Robdel12 for the information and detailed answer on how Percy works with assets of a web app. I learnt a lot reading that explanation. Still, there is something not clear to me yet: Even the Service Worker provided by For my personal knowledge and learning opportunity:
|
Does anyone have a sample repo with a workaround solution with http-middleware? |
One workaround could be to add a custom user agent config to Percy's asset discovery browser: https://docs.percy.io/docs/cli-configuration#discovery then when that UA is detected in storybook you would disable this addon.
Percy is doing request interception at the browser level via CDP. So any network request that runs through the browser will be seen & processed by the SDK. |
I've came up with the following code placed in const cors = require('cors');
const bodyParser = require('body-parser');
const { createMiddleware } = require('@mswjs/http-middleware');
const handlersQueries = require('./mocks/handler');
const mockServiceWorkerMiddleware = router => {
router.use(cors());
router.use(bodyParser.urlencoded({
extended: true
}));
router.use(bodyParser.json());
router.use(createMiddleware(
...handlersQueries
));
};
module.exports = mockServiceWorkerMiddleware; Few notes:
This solution does seem to work with |
Is there a way to use @andrzej-kodify |
@oscard0m nothing obvious that I can think of here :( |
Also, @andrzej-kodify, does your example cover mock requests of external URL's or only localhost/? I'm having problems with that right now but I'm guessing |
@oscard0m only localhost, you could try to modify request url before it's sent or add an entry hooking given domain to 127.0.0.1 in the system hosts file to capture other traffic |
Just for the ones interested: Until this issue moves forward, the temporal solution we are using in our company is storybook-addon-mock. It does not rely on a Service Worker so Percy seems to like it. |
I am interested in a resolution for this issue. We are moving to MSW more widely at my organization, but we have a lot of apps that use This doesn't seem to be an issue when using percy with other techs (e.g. capybara or webdriverio) - is there an explanation for that? It also looks like playwright made progress on this, maybe that can help inform a direction here: microsoft/playwright#1090 |
@joekur I went through this thread right now. We would have to check the viability of supporting MSW based stories. As you have already reported this in a support ticket, we would look into this and update on it. |
Hello everyone, Feel free to give it a try and share your feedback at https://github.com/percy/percy-storybook. |
@oscard0m can we close this discussion as with official support for the plugin its resolved ? |
We are using Chromatic for our projects so I can't check, but I assume it can be closed if there's official support. |
@IsidorusHispalensis / @oscard0m can you close the issue as a reporter/maintainer ? |
I don't have permissions to do it. |
We are using MSW to run visual regression using Percy and recent update of npm packages leads to timeouts in E2E tests.
Unfortunately the repo is private and I am not able to share it but I can create an empty one if you want, steps to reproduce:
In interactive mode I can see Chromium is doing multiple page reloads when MSW is attached, and removing initializeWorker() from preview.js clearly solves the problem. Any help to get directions where to continue digging is extremely appreciated
The text was updated successfully, but these errors were encountered: