Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #196 from cloudinary/APPS-7306-add-devtools-networ…
Browse files Browse the repository at this point in the history
…k-test

Apps 7306 add devtools network test
  • Loading branch information
refael-m authored Jan 3, 2021
2 parents b3fae4a + c42dd08 commit fba809e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/test/specs/startNetworkAuditSpec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { describeCommon, sampleAppUrl } from '../TestHelper';
import { BrowserUtils } from '../..';

interface NetworkLog {
url: string;
status: number;
}

/**
* DevTools - Start network audit
*/
describeCommon('startNetworkAudit', () => {
it('successfully start and read network audit', () => {
const expectedLog: NetworkLog = { url: 'http://placekitten.com/480/480', status: 200 };
const networkLogs: Array<NetworkLog> = [];

browser.on('Network.responseReceived', (params: any) => {
networkLogs.push({
url: params.response.url,
status: Number(params.response.status),
});
});

BrowserUtils.navigateToUrl(sampleAppUrl);

BrowserUtils.waitUntil(
() => {
return networkLogs.some((log) => log.url === expectedLog.url && Number(log.status) === expectedLog.status);
},
`Expected log [${JSON.stringify(expectedLog)}] was not found`,
5000
);
});
});
3 changes: 2 additions & 1 deletion src/test/wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ exports.config = {
// your test setup with almost no effort. Unlike plugins, they don't add new
// commands. Instead, they hook themselves up into the test process.
services: [
[
['devtools'],
[
'selenium-standalone',
{
installArgs: seleniumStandaloneArgs,
Expand Down

0 comments on commit fba809e

Please sign in to comment.