chore: opt out of trace attachments (#23139)
Fixes: https://github.com/microsoft/playwright/issues/23137
This commit is contained in:
parent
a1fc8ff07d
commit
3395a28181
|
|
@ -526,6 +526,7 @@ export default defineConfig({
|
||||||
* since: v1.10
|
* since: v1.10
|
||||||
- type: <[Object]|[TraceMode]<"off"|"on"|"retain-on-failure"|"on-first-retry">>
|
- type: <[Object]|[TraceMode]<"off"|"on"|"retain-on-failure"|"on-first-retry">>
|
||||||
- `mode` <[TraceMode]<"off"|"on"|"retain-on-failure"|"on-first-retry"|"on-all-retries">> Trace recording mode.
|
- `mode` <[TraceMode]<"off"|"on"|"retain-on-failure"|"on-first-retry"|"on-all-retries">> Trace recording mode.
|
||||||
|
- `attachments` ?<[boolean]> Whether to include test attachments. Defaults to true. Optional.
|
||||||
- `screenshots` ?<[boolean]> Whether to capture screenshots during tracing. Screenshots are used to build a timeline preview. Defaults to true. Optional.
|
- `screenshots` ?<[boolean]> Whether to capture screenshots during tracing. Screenshots are used to build a timeline preview. Defaults to true. Optional.
|
||||||
- `snapshots` ?<[boolean]> Whether to capture DOM snapshot on every action. Defaults to true. Optional.
|
- `snapshots` ?<[boolean]> Whether to capture DOM snapshot on every action. Defaults to true. Optional.
|
||||||
- `sources` ?<[boolean]> Whether to include source files for trace actions. Defaults to true. Optional.
|
- `sources` ?<[boolean]> Whether to include source files for trace actions. Defaults to true. Optional.
|
||||||
|
|
|
||||||
|
|
@ -558,7 +558,7 @@ class ArtifactsRecorder {
|
||||||
private _traceMode: TraceMode;
|
private _traceMode: TraceMode;
|
||||||
private _captureTrace = false;
|
private _captureTrace = false;
|
||||||
private _screenshotOptions: { mode: ScreenshotMode } & Pick<playwrightLibrary.PageScreenshotOptions, 'fullPage' | 'omitBackground'> | undefined;
|
private _screenshotOptions: { mode: ScreenshotMode } & Pick<playwrightLibrary.PageScreenshotOptions, 'fullPage' | 'omitBackground'> | undefined;
|
||||||
private _traceOptions: { screenshots: boolean, snapshots: boolean, sources: boolean, mode?: TraceMode };
|
private _traceOptions: { screenshots: boolean, snapshots: boolean, sources: boolean, attachments: boolean, mode?: TraceMode };
|
||||||
private _temporaryTraceFiles: string[] = [];
|
private _temporaryTraceFiles: string[] = [];
|
||||||
private _temporaryScreenshots: string[] = [];
|
private _temporaryScreenshots: string[] = [];
|
||||||
private _reusedContexts = new Set<BrowserContext>();
|
private _reusedContexts = new Set<BrowserContext>();
|
||||||
|
|
@ -572,7 +572,7 @@ class ArtifactsRecorder {
|
||||||
this._screenshotMode = normalizeScreenshotMode(screenshot);
|
this._screenshotMode = normalizeScreenshotMode(screenshot);
|
||||||
this._screenshotOptions = typeof screenshot === 'string' ? undefined : screenshot;
|
this._screenshotOptions = typeof screenshot === 'string' ? undefined : screenshot;
|
||||||
this._traceMode = normalizeTraceMode(trace);
|
this._traceMode = normalizeTraceMode(trace);
|
||||||
const defaultTraceOptions = { screenshots: true, snapshots: true, sources: true };
|
const defaultTraceOptions = { screenshots: true, snapshots: true, sources: true, attachments: true };
|
||||||
this._traceOptions = typeof trace === 'string' ? defaultTraceOptions : { ...defaultTraceOptions, ...trace, mode: undefined };
|
this._traceOptions = typeof trace === 'string' ? defaultTraceOptions : { ...defaultTraceOptions, ...trace, mode: undefined };
|
||||||
this._screenshottedSymbol = Symbol('screenshotted');
|
this._screenshottedSymbol = Symbol('screenshotted');
|
||||||
this._startedCollectingArtifacts = Symbol('startedCollectingArtifacts');
|
this._startedCollectingArtifacts = Symbol('startedCollectingArtifacts');
|
||||||
|
|
@ -661,6 +661,12 @@ class ArtifactsRecorder {
|
||||||
if (this._preserveTrace()) {
|
if (this._preserveTrace()) {
|
||||||
const events = this._testInfo._traceEvents;
|
const events = this._testInfo._traceEvents;
|
||||||
if (events.length) {
|
if (events.length) {
|
||||||
|
if (!this._traceOptions.attachments) {
|
||||||
|
for (const event of events) {
|
||||||
|
if (event.type === 'after')
|
||||||
|
delete event.attachments;
|
||||||
|
}
|
||||||
|
}
|
||||||
const tracePath = path.join(this._artifactsDir, createGuid() + '.zip');
|
const tracePath = path.join(this._artifactsDir, createGuid() + '.zip');
|
||||||
this._temporaryTraceFiles.push(tracePath);
|
this._temporaryTraceFiles.push(tracePath);
|
||||||
await saveTraceFile(tracePath, events, this._traceOptions.sources);
|
await saveTraceFile(tracePath, events, this._traceOptions.sources);
|
||||||
|
|
|
||||||
2
packages/playwright-test/types/test.d.ts
vendored
2
packages/playwright-test/types/test.d.ts
vendored
|
|
@ -3554,7 +3554,7 @@ export interface PlaywrightWorkerOptions {
|
||||||
*
|
*
|
||||||
* Learn more about [recording trace](https://playwright.dev/docs/test-configuration#record-test-trace).
|
* Learn more about [recording trace](https://playwright.dev/docs/test-configuration#record-test-trace).
|
||||||
*/
|
*/
|
||||||
trace: TraceMode | /** deprecated */ 'retry-with-trace' | { mode: TraceMode, snapshots?: boolean, screenshots?: boolean, sources?: boolean };
|
trace: TraceMode | /** deprecated */ 'retry-with-trace' | { mode: TraceMode, snapshots?: boolean, screenshots?: boolean, sources?: boolean, attachments?: boolean };
|
||||||
/**
|
/**
|
||||||
* Whether to record video for each test. Defaults to `'off'`.
|
* Whether to record video for each test. Defaults to `'off'`.
|
||||||
* - `'off'`: Do not record video.
|
* - `'off'`: Do not record video.
|
||||||
|
|
|
||||||
2
utils/generate_types/overrides-test.d.ts
vendored
2
utils/generate_types/overrides-test.d.ts
vendored
|
|
@ -206,7 +206,7 @@ export interface PlaywrightWorkerOptions {
|
||||||
launchOptions: LaunchOptions;
|
launchOptions: LaunchOptions;
|
||||||
connectOptions: ConnectOptions | undefined;
|
connectOptions: ConnectOptions | undefined;
|
||||||
screenshot: ScreenshotMode | { mode: ScreenshotMode } & Pick<PageScreenshotOptions, 'fullPage' | 'omitBackground'>;
|
screenshot: ScreenshotMode | { mode: ScreenshotMode } & Pick<PageScreenshotOptions, 'fullPage' | 'omitBackground'>;
|
||||||
trace: TraceMode | /** deprecated */ 'retry-with-trace' | { mode: TraceMode, snapshots?: boolean, screenshots?: boolean, sources?: boolean };
|
trace: TraceMode | /** deprecated */ 'retry-with-trace' | { mode: TraceMode, snapshots?: boolean, screenshots?: boolean, sources?: boolean, attachments?: boolean };
|
||||||
video: VideoMode | /** deprecated */ 'retry-with-video' | { mode: VideoMode, size?: ViewportSize };
|
video: VideoMode | /** deprecated */ 'retry-with-video' | { mode: VideoMode, size?: ViewportSize };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue