-
Notifications
You must be signed in to change notification settings - Fork 47
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
Capture service worker intercepted requests #1443
Capture service worker intercepted requests #1443
Conversation
…re-service-worker-intercepted-requests
…re-service-worker-intercepted-requests
packages/core/src/discovery.js
Outdated
@@ -288,6 +289,7 @@ export function createDiscoveryQueue(percy) { | |||
requestHeaders: snapshot.discovery.requestHeaders, | |||
authorization: snapshot.discovery.authorization, | |||
userAgent: snapshot.discovery.userAgent, | |||
captureServiceWorker: snapshot.discovery.captureServiceWorker, |
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.
per-snapshot level vs global config I'd commented in storybook PR. lets decide what to use and make it uniform.
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.
snapshot.discovery.captureServiceWorker
will contain global value, can you verify once?
packages/core/src/snapshot.js
Outdated
@@ -114,6 +114,7 @@ function getSnapshotOptions(options, { config, meta }) { | |||
requestHeaders: config.discovery.requestHeaders, | |||
authorization: config.discovery.authorization, | |||
disableCache: config.discovery.disableCache, | |||
captureServiceWorker: config.discovery.captureServiceWorker, |
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.
okay we're overriding it here so no issues.
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.
can you link locking CLI pr?
The base branch for this one is https://github.com/percy/cli/tree/refactor-network-js. |
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!
#1441) * feat: added defaultmap + locking mechanism for intercepts queue * feat: added checkResponseSent lock * chore: add comments + rename variables * refactor: move DefaultMap to core/utils * feat: track lifecycle for ALL requests, does not matter if nterwork is intercepted or not * feat: add locking mechanism for Network.loadingFailed and Network.eventSourceMessageReceived * refactor: lock names in requestLifeCycle * chore: lint fix * fix: coverage issue with single if blocks * test: added defaultMap specs * chore: remove unused intercepts map * Capture service worker intercepted requests (#1443) * feat: added new config discovery.captureServiceWorker * feat: use captureServiceWorker config to capture original requests * chore: lint fix * test: added spec for captureServiceWorker * chore: rename captureServiceWorker -> captureMockedServiceWorker
Changes:
captureMockedServiceWorker
flag underdiscovery
for capturing service worker requestsbypass: false
forNetwork.setBypassServiceWorker
so that service-worker controller can be added and we can access the MSW mocks customer has added.serviceWorker
parameter, to handleRequests that are not intercepted (since service worker intercepted and will resolve them)Detailed Changes & Reasoning:
Network.setBypassServiceWorker
tobypass: false
so that we can add service-worker controller and access service worker that mocks customer's data.Network.getResponseBody
, but over herebody
is returned as""
(empty string) randomly.Network.getResponseBody
on the original request which service-worker intercepted.Network.getResponseBody
is same as what appears in theResponse
tab in Network section in devtools.Response
tab is always populated.body: ""
whenNetwork.getResponseBody
is called on it.Network.getResponseBody
on the original request itself.Related PRs:
percy/percy-storybook#845