Skip to content

Commit

Permalink
Revert withTracing changes that were extracted to microsoft#1751
Browse files Browse the repository at this point in the history
  • Loading branch information
dbjorge committed Nov 26, 2019
1 parent 80b90a3 commit 0b2b5e3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 40 deletions.
36 changes: 0 additions & 36 deletions src/tests/end-to-end/common/page-controllers/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import { includes } from 'lodash';
import * as Puppeteer from 'puppeteer';

import { createDefaultPromiseFactory } from 'common/promises/promise-factory';
import { generateUID } from 'common/uid-generator';
import * as makeDir from 'make-dir';
import * as path from 'path';
import { CommonSelectors } from '../element-identifiers/common-selectors';
import { forceTestFailure } from '../force-test-failure';
import { takeScreenshot } from '../generate-screenshot';
Expand Down Expand Up @@ -303,37 +300,4 @@ export class Page {
await this.underlyingPage.addScriptTag({ path: filePath });
});
}

public async withTracing<T>(wrappedFn: () => Promise<T>): Promise<T> {
const tracingPath = path.resolve(__dirname, '../../../../../test-results/e2e/tracing');
const toFilename = (s: string) => s.replace(/[^a-z0-9.-]+/gi, '_');
await makeDir(tracingPath);
const traceName = generateUID();
const filePath = path.join(tracingPath, toFilename(`${traceName}.json`));
const options: Puppeteer.TracingStartOptions = { path: filePath, screenshots: true };
await this.underlyingPage.tracing.start(options);

let retVal: T;
try {
retVal = await wrappedFn();
} catch (originalError) {
try {
await this.underlyingPage.tracing.stop();
// Only log this after tracing.stop succeeds!
console.log(`Trace file (from error) is located at: ${filePath}`);
} catch (secondaryTracingStopError) {
console.error(
`withTracing: Detected an error, and then *additionally* hit a second error while trying to call tracing.stop() after the first error.\n` +
`withTracing: The secondary error from tracing.stop() is: ${secondaryTracingStopError.stack}\n` +
`withTracing: rethrowing the original error...`,
);
}
throw originalError;
}
await this.underlyingPage.tracing.stop();

// Only log this after tracing.stop!
console.log(`Trace file (from success) is located at: ${filePath}`);
return retVal;
}
}
6 changes: 2 additions & 4 deletions src/tests/end-to-end/tests/popup/adhoc-panel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ describe('Popup -> Ad-hoc tools', () => {
it.each(['Automated checks', 'Landmarks', 'Headings', 'Color'])(
'should display the pinned target page visualizations when enabling the "%s" toggle',
async (toggleAriaLabel: string) => {
await popupPage.withTracing(async () => {
await popupPage.gotoAdhocPanel();
await popupPage.enableToggleByAriaLabel(toggleAriaLabel);
});
await popupPage.gotoAdhocPanel();
await popupPage.enableToggleByAriaLabel(toggleAriaLabel);

await targetPage.bringToFront();
expect(await targetPage.waitForShadowRootHtmlSnapshot()).toMatchSnapshot();
Expand Down

0 comments on commit 0b2b5e3

Please sign in to comment.