Skip to content

Commit

Permalink
Check browser before starting CPD session
Browse files Browse the repository at this point in the history
Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>
  • Loading branch information
krassowski and fcollonval committed Dec 13, 2023
1 parent b0d7bce commit cd42ea6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions galata/src/helpers/performance.ts
Expand Up @@ -47,13 +47,18 @@ export class PerformanceHelper {
downloadThroughput: number;
uploadThroughput: number;
latency: number;
}): Promise<CDPSession> {
const cdpSession = await this.page.context().newCDPSession(this.page);
await cdpSession.send('Network.emulateNetworkConditions', {
offline: false,
...config
});
return cdpSession;
}): Promise<CDPSession | null> {
const browserName = this.page.context().browser().browserType().name();
if (browserName === 'chromium') {
const cdpSession = await this.page.context().newCDPSession(this.page);
await cdpSession.send('Network.emulateNetworkConditions', {
offline: false,
...config
});
return cdpSession;
}
console.log('Browser does not support throttling network');
return null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion galata/test/jupyterlab/completer.test.ts
Expand Up @@ -86,7 +86,7 @@ test.describe('Completer', () => {
await page.waitForSelector('.jp-Completer-loading-bar', {
state: 'detached'
});
await session.detach();
await session?.detach();
const imageName = 'completer-with-doc-panel.png';
expect(await completer.screenshot()).toMatchSnapshot(imageName);
});
Expand Down

0 comments on commit cd42ea6

Please sign in to comment.