chore: remove/rename FullConfig._attachments (#13233)
This was originally introduced in #12734. It will be replaced with GlobalInfo (#13083), but not before the 1.21 release.
This commit is contained in:
parent
e5ba0d6846
commit
16efbdef98
|
|
@ -720,16 +720,3 @@ const config: PlaywrightTestConfig = {
|
||||||
};
|
};
|
||||||
export default config;
|
export default config;
|
||||||
```
|
```
|
||||||
|
|
||||||
## property: TestConfig.attachments
|
|
||||||
- type: <[Array]<[Object]>>
|
|
||||||
- `name` <[string]> Attachment name.
|
|
||||||
- `contentType` <[string]> Content type of this attachment to properly present in the report, for example `'application/json'` or `'image/png'`.
|
|
||||||
- `path` <[void]|[string]> Optional path on the filesystem to the attached file.
|
|
||||||
- `body` <[void]|[Buffer]> Optional attachment body used instead of a file.
|
|
||||||
|
|
||||||
:::note
|
|
||||||
This does not include test-level attachments. See [`method: TestInfo.attach`] and [`property: TestInfo.attachments`] for working with test-level attachments.
|
|
||||||
:::
|
|
||||||
|
|
||||||
The list of files or buffers attached for the overall Playwright Test run. Some reporters show attachments.
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ module.exports = {
|
||||||
],
|
],
|
||||||
'reporters': [
|
'reporters': [
|
||||||
'../types/testReporter.d.ts',
|
'../types/testReporter.d.ts',
|
||||||
|
'./types.ts',
|
||||||
'util.ts',
|
'util.ts',
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -473,7 +473,7 @@ const baseFullConfig: FullConfigInternal = {
|
||||||
version: require('../package.json').version,
|
version: require('../package.json').version,
|
||||||
workers: 1,
|
workers: 1,
|
||||||
webServer: null,
|
webServer: null,
|
||||||
attachments: [],
|
_attachments: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
function resolveReporters(reporters: Config['reporter'], rootDir: string): ReporterDescription[]|undefined {
|
function resolveReporters(reporters: Config['reporter'], rootDir: string): ReporterDescription[]|undefined {
|
||||||
|
|
|
||||||
|
|
@ -20,13 +20,7 @@ import { FullConfig, TestCase, Suite, TestResult, TestError, TestStep, FullResul
|
||||||
import { prepareErrorStack } from './base';
|
import { prepareErrorStack } from './base';
|
||||||
|
|
||||||
export interface JSONReport {
|
export interface JSONReport {
|
||||||
config: Omit<FullConfig, 'projects' | 'attachments'> & {
|
config: Omit<FullConfig, 'projects'> & {
|
||||||
attachments: {
|
|
||||||
name: string;
|
|
||||||
path?: string;
|
|
||||||
body?: string;
|
|
||||||
contentType: string;
|
|
||||||
}[];
|
|
||||||
projects: {
|
projects: {
|
||||||
outputDir: string,
|
outputDir: string,
|
||||||
repeatEach: number,
|
repeatEach: number,
|
||||||
|
|
@ -127,12 +121,6 @@ class JSONReporter implements Reporter {
|
||||||
return {
|
return {
|
||||||
config: {
|
config: {
|
||||||
...this.config,
|
...this.config,
|
||||||
attachments: this.config.attachments.map(a => ({
|
|
||||||
name: a.name,
|
|
||||||
contentType: a.contentType,
|
|
||||||
path: a.path,
|
|
||||||
body: a.body?.toString('base64')
|
|
||||||
})),
|
|
||||||
rootDir: toPosixPath(this.config.rootDir),
|
rootDir: toPosixPath(this.config.rootDir),
|
||||||
projects: this.config.projects.map(project => {
|
projects: this.config.projects.map(project => {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import { formatResultFailure } from './base';
|
||||||
import { toPosixPath, serializePatterns } from './json';
|
import { toPosixPath, serializePatterns } from './json';
|
||||||
import { MultiMap } from 'playwright-core/lib/utils/multimap';
|
import { MultiMap } from 'playwright-core/lib/utils/multimap';
|
||||||
import { codeFrameColumns } from '@babel/code-frame';
|
import { codeFrameColumns } from '@babel/code-frame';
|
||||||
|
import { FullConfigInternal } from '../types';
|
||||||
|
|
||||||
export type JsonLocation = Location;
|
export type JsonLocation = Location;
|
||||||
export type JsonError = string;
|
export type JsonError = string;
|
||||||
|
|
@ -134,7 +135,7 @@ class RawReporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
generateAttachments(config: FullConfig): JsonAttachment[] {
|
generateAttachments(config: FullConfig): JsonAttachment[] {
|
||||||
return this._createAttachments(config.attachments);
|
return this._createAttachments((config as FullConfigInternal)._attachments);
|
||||||
}
|
}
|
||||||
|
|
||||||
generateProjectReport(config: FullConfig, suite: Suite): JsonReport {
|
generateProjectReport(config: FullConfig, suite: Suite): JsonReport {
|
||||||
|
|
|
||||||
|
|
@ -40,4 +40,5 @@ export interface TestStepInternal {
|
||||||
* increasing the surface area of the public API type called FullConfig.
|
* increasing the surface area of the public API type called FullConfig.
|
||||||
*/
|
*/
|
||||||
export interface FullConfigInternal extends FullConfigPublic {
|
export interface FullConfigInternal extends FullConfigPublic {
|
||||||
|
_attachments: { name: string, path?: string, body?: Buffer, contentType: string }[];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
9
packages/playwright-test/types/test.d.ts
vendored
9
packages/playwright-test/types/test.d.ts
vendored
|
|
@ -1277,15 +1277,6 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
webServer: WebServerConfig | null;
|
webServer: WebServerConfig | null;
|
||||||
/**
|
|
||||||
* > NOTE: This does not include test-level attachments. See
|
|
||||||
* [testInfo.attach(name[, options])](https://playwright.dev/docs/api/class-testinfo#test-info-attach) and
|
|
||||||
* [testInfo.attachments](https://playwright.dev/docs/api/class-testinfo#test-info-attachments) for working with test-level
|
|
||||||
* attachments.
|
|
||||||
*
|
|
||||||
* The list of files or buffers attached for the overall Playwright Test run. Some reporters show attachments.
|
|
||||||
*/
|
|
||||||
attachments: { name: string, path?: string, body?: Buffer, contentType: string }[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TestStatus = 'passed' | 'failed' | 'timedOut' | 'skipped';
|
export type TestStatus = 'passed' | 'failed' | 'timedOut' | 'skipped';
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import { FullConfig } from '@playwright/test';
|
||||||
import * as ci from '@playwright/test/lib/ci';
|
import * as ci from '@playwright/test/lib/ci';
|
||||||
|
|
||||||
async function globalSetup(config: FullConfig) {
|
async function globalSetup(config: FullConfig) {
|
||||||
config.attachments = [
|
(config as any)._attachments = [
|
||||||
...await ci.generationTimestamp(),
|
...await ci.generationTimestamp(),
|
||||||
...await ci.gitStatusFromCLI(config.rootDir),
|
...await ci.gitStatusFromCLI(config.rootDir),
|
||||||
...await ci.githubEnv(),
|
...await ci.githubEnv(),
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ test(`TestConfig.attachments works`, async ({ runInlineTest }) => {
|
||||||
import { FullConfig } from '@playwright/test';
|
import { FullConfig } from '@playwright/test';
|
||||||
|
|
||||||
async function globalSetup(config: FullConfig) {
|
async function globalSetup(config: FullConfig) {
|
||||||
config.attachments = [{ contentType: 'text/plain', body: Buffer.from('example data'), name: 'my-attachment.txt' }];
|
(config as any)._attachments = [{ contentType: 'text/plain', body: Buffer.from('example data'), name: 'my-attachment.txt' }];
|
||||||
};
|
};
|
||||||
|
|
||||||
export default globalSetup;
|
export default globalSetup;
|
||||||
|
|
@ -213,7 +213,7 @@ test(`TestConfig.attachments works`, async ({ runInlineTest }) => {
|
||||||
}, { reporter: 'json' });
|
}, { reporter: 'json' });
|
||||||
|
|
||||||
expect(result.exitCode).toBe(0);
|
expect(result.exitCode).toBe(0);
|
||||||
expect(result.report.config.attachments).toHaveLength(1);
|
expect((result.report.config as any)._attachments).toHaveLength(1);
|
||||||
expect(result.report.config.attachments[0].name).toBe('my-attachment.txt');
|
expect((result.report.config as any)._attachments[0].name).toBe('my-attachment.txt');
|
||||||
expect(Buffer.from(result.report.config.attachments[0].body, 'base64').toString()).toBe('example data');
|
expect(Buffer.from((result.report.config as any)._attachments[0].body, 'base64').toString()).toBe('example data');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -711,7 +711,7 @@ test('should include metadata', async ({ runInlineTest, showReport, page }) => {
|
||||||
import { FullConfig } from '@playwright/test';
|
import { FullConfig } from '@playwright/test';
|
||||||
|
|
||||||
async function globalSetup(config: FullConfig) {
|
async function globalSetup(config: FullConfig) {
|
||||||
config.attachments = [
|
(config as any)._attachments = [
|
||||||
...await ci.generationTimestamp(),
|
...await ci.generationTimestamp(),
|
||||||
...await ci.gitStatusFromCLI(config.rootDir),
|
...await ci.gitStatusFromCLI(config.rootDir),
|
||||||
...await ci.githubEnv(),
|
...await ci.githubEnv(),
|
||||||
|
|
|
||||||
1
utils/generate_types/overrides-test.d.ts
vendored
1
utils/generate_types/overrides-test.d.ts
vendored
|
|
@ -223,7 +223,6 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
|
||||||
updateSnapshots: UpdateSnapshots;
|
updateSnapshots: UpdateSnapshots;
|
||||||
workers: number;
|
workers: number;
|
||||||
webServer: WebServerConfig | null;
|
webServer: WebServerConfig | null;
|
||||||
attachments: { name: string, path?: string, body?: Buffer, contentType: string }[];
|
|
||||||
// [internal] !!! DO NOT ADD TO THIS !!! See prior note.
|
// [internal] !!! DO NOT ADD TO THIS !!! See prior note.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue