Skip to content

Commit

Permalink
chore: rename captureServiceWorker -> captureMockedServiceWorker
Browse files Browse the repository at this point in the history
  • Loading branch information
nilshah98 committed Nov 28, 2023
1 parent ac51d95 commit 870f763
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export const configSchema = {
disableCache: {
type: 'boolean'
},
captureServiceWorker: {
captureMockedServiceWorker: {
type: 'boolean',
default: false
},
Expand Down Expand Up @@ -253,7 +253,7 @@ export const snapshotSchema = {
requestHeaders: { $ref: '/config/discovery#/properties/requestHeaders' },
authorization: { $ref: '/config/discovery#/properties/authorization' },
disableCache: { $ref: '/config/discovery#/properties/disableCache' },
captureServiceWorker: { $ref: '/config/discovery#/properties/captureServiceWorker' },
captureMockedServiceWorker: { $ref: '/config/discovery#/properties/captureMockedServiceWorker' },
userAgent: { $ref: '/config/discovery#/properties/userAgent' },
devicePixelRatio: { $ref: '/config/discovery#/properties/devicePixelRatio' }
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function debugSnapshotOptions(snapshot) {
debugProp(snapshot, 'discovery.requestHeaders', JSON.stringify);
debugProp(snapshot, 'discovery.authorization', JSON.stringify);
debugProp(snapshot, 'discovery.disableCache');
debugProp(snapshot, 'discovery.captureServiceWorker');
debugProp(snapshot, 'discovery.captureMockedServiceWorker');
debugProp(snapshot, 'discovery.userAgent');
debugProp(snapshot, 'clientInfo');
debugProp(snapshot, 'environmentInfo');
Expand Down Expand Up @@ -289,7 +289,7 @@ export function createDiscoveryQueue(percy) {
requestHeaders: snapshot.discovery.requestHeaders,
authorization: snapshot.discovery.authorization,
userAgent: snapshot.discovery.userAgent,
captureServiceWorker: snapshot.discovery.captureServiceWorker,
captureMockedServiceWorker: snapshot.discovery.captureMockedServiceWorker,
meta: snapshot.meta,

// enable network inteception
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Network {
this.timeout = options.networkIdleTimeout ?? 100;
this.authorization = options.authorization;
this.requestHeaders = options.requestHeaders ?? {};
this.captureServiceWorker = options.captureServiceWorker ?? false;
this.captureMockedServiceWorker = options.captureMockedServiceWorker ?? false;
this.userAgent = options.userAgent ??
// by default, emulate a non-headless browser
page.session.browser.version.userAgent.replace('Headless', '');
Expand All @@ -55,7 +55,7 @@ export class Network {

let commands = [
session.send('Network.enable'),
session.send('Network.setBypassServiceWorker', { bypass: !this.captureServiceWorker }),
session.send('Network.setBypassServiceWorker', { bypass: !this.captureMockedServiceWorker }),
session.send('Network.setCacheDisabled', { cacheDisabled: true }),
session.send('Network.setUserAgentOverride', { userAgent: this.userAgent }),
session.send('Network.setExtraHTTPHeaders', { headers: this.requestHeaders })
Expand Down Expand Up @@ -186,7 +186,7 @@ export class Network {

if (this.intercept) {
this.#pending.set(requestId, event);
if (this.captureServiceWorker) {
if (this.captureMockedServiceWorker) {
await this._handleRequest(undefined, { ...event, resourceType: type, interceptId: requestId }, true);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function getSnapshotOptions(options, { config, meta }) {
requestHeaders: config.discovery.requestHeaders,
authorization: config.discovery.authorization,
disableCache: config.discovery.disableCache,
captureServiceWorker: config.discovery.captureServiceWorker,
captureMockedServiceWorker: config.discovery.captureMockedServiceWorker,
userAgent: config.discovery.userAgent
}
}, options], (path, prev, next) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/discovery.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,7 @@ describe('Discovery', () => {
url: 'http://localhost:8000',
waitForSelector: '#injected-image',
discovery: {
captureServiceWorker: true
captureMockedServiceWorker: true
}
});

Expand Down
2 changes: 1 addition & 1 deletion packages/core/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface DiscoveryOptions {
authorization?: AuthCredentials;
allowedHostnames?: string[];
disableCache?: boolean;
captureServiceWorker?: boolean;
captureMockedServiceWorker?: boolean;
}

interface DiscoveryLaunchOptions {
Expand Down

0 comments on commit 870f763

Please sign in to comment.