mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix: types generation for attach and GlobalInfo (#13727)
This commit is contained in:
parent
d2bdb1d7cf
commit
8e5854033a
@ -111,13 +111,21 @@ after awaiting the attach call.
|
||||
:::
|
||||
|
||||
### param: GlobalInfo.attach.name
|
||||
- `name` <[string]> Attachment name.
|
||||
- `name` <[string]>
|
||||
|
||||
Attachment name.
|
||||
|
||||
### option: GlobalInfo.attach.body
|
||||
- `body` ?<[string]|[Buffer]> Attachment body. Mutually exclusive with [`option: path`].
|
||||
- `body` ?<[string]|[Buffer]>
|
||||
|
||||
Attachment body. Mutually exclusive with [`option: path`].
|
||||
|
||||
### option: GlobalInfo.attach.contentType
|
||||
- `contentType` ?<[string]> Optional content type of this attachment to properly present in the report, for example `'application/json'` or `'image/png'`. If omitted, content type is inferred based on the [`option: path`], or defaults to `text/plain` for [string] attachments and `application/octet-stream` for [Buffer] attachments.
|
||||
- `contentType` ?<[string]>
|
||||
|
||||
Optional content type of this attachment to properly present in the report, for example `'application/json'` or `'image/png'`. If omitted, content type is inferred based on the [`option: path`], or defaults to `text/plain` for [string] attachments and `application/octet-stream` for [Buffer] attachments.
|
||||
|
||||
### option: GlobalInfo.attach.path
|
||||
- `path` ?<[string]> Path on the filesystem to the attached file. Mutually exclusive with [`option: body`].
|
||||
- `path` ?<[string]>
|
||||
|
||||
Path on the filesystem to the attached file. Mutually exclusive with [`option: body`].
|
||||
|
||||
@ -97,16 +97,24 @@ after awaiting the attach call.
|
||||
:::
|
||||
|
||||
### param: TestInfo.attach.name
|
||||
- `name` <[string]> Attachment name.
|
||||
- `name` <[string]>
|
||||
|
||||
Attachment name.
|
||||
|
||||
### option: TestInfo.attach.body
|
||||
- `body` <[string]|[Buffer]> Attachment body. Mutually exclusive with [`option: path`].
|
||||
- `body` <[string]|[Buffer]>
|
||||
|
||||
Attachment body. Mutually exclusive with [`option: path`].
|
||||
|
||||
### option: TestInfo.attach.contentType
|
||||
- `contentType` <[string]> Content type of this attachment to properly present in the report, for example `'application/json'` or `'image/png'`. If omitted, content type is inferred based on the [`option: path`], or defaults to `text/plain` for [string] attachments and `application/octet-stream` for [Buffer] attachments.
|
||||
- `contentType` <[string]>
|
||||
|
||||
Content type of this attachment to properly present in the report, for example `'application/json'` or `'image/png'`. If omitted, content type is inferred based on the [`option: path`], or defaults to `text/plain` for [string] attachments and `application/octet-stream` for [Buffer] attachments.
|
||||
|
||||
### option: TestInfo.attach.path
|
||||
- `path` <[string]> Path on the filesystem to the attached file. Mutually exclusive with [`option: body`].
|
||||
- `path` <[string]>
|
||||
|
||||
Path on the filesystem to the attached file. Mutually exclusive with [`option: body`].
|
||||
|
||||
|
||||
## property: TestInfo.column
|
||||
|
||||
207
packages/playwright-test/types/test.d.ts
vendored
207
packages/playwright-test/types/test.d.ts
vendored
@ -1465,14 +1465,25 @@ export interface TestInfo {
|
||||
* > NOTE: [testInfo.attach(name[, options])](https://playwright.dev/docs/api/class-testinfo#test-info-attach)
|
||||
* automatically takes care of copying attached files to a location that is accessible to reporters. You can safely remove
|
||||
* the attachment after awaiting the attach call.
|
||||
* @param name
|
||||
* @param name Attachment name.
|
||||
* @param options
|
||||
*/
|
||||
attach(name: string, options?: {
|
||||
/**
|
||||
* Attachment body. Mutually exclusive with `path`.
|
||||
*/
|
||||
body?: string|Buffer;
|
||||
|
||||
/**
|
||||
* Content type of this attachment to properly present in the report, for example `'application/json'` or `'image/png'`. If
|
||||
* omitted, content type is inferred based on the `path`, or defaults to `text/plain` for [string] attachments and
|
||||
* `application/octet-stream` for [Buffer] attachments.
|
||||
*/
|
||||
contentType?: string;
|
||||
|
||||
/**
|
||||
* Path on the filesystem to the attached file. Mutually exclusive with `body`.
|
||||
*/
|
||||
path?: string;
|
||||
}): Promise<void>;
|
||||
|
||||
@ -1734,84 +1745,6 @@ export interface TestInfo {
|
||||
*/
|
||||
workerIndex: number;}
|
||||
|
||||
/**
|
||||
* `GlobalInfo` contains information on the overall test run. The information spans projects and tests. Some reporters show
|
||||
* global info.
|
||||
*
|
||||
* You can write to GlobalInfo via your Global Setup hook, and read from it in a [Custom Reporter](https://playwright.dev/docs/test-reporters):
|
||||
*
|
||||
* ```ts
|
||||
* // global-setup.ts
|
||||
* import { chromium, FullConfig, GlobalInfo } from '@playwright/test';
|
||||
*
|
||||
* async function globalSetup(config: FullConfig, info: GlobalInfo) {
|
||||
* await info.attach('agent.config.txt', { path: './agent.config.txt' });
|
||||
* }
|
||||
*
|
||||
* export default globalSetup;
|
||||
* ```
|
||||
*
|
||||
* Access the attachments from the Root Suite in the Reporter:
|
||||
*
|
||||
* ```ts
|
||||
* // my-awesome-reporter.ts
|
||||
* import { Reporter } from '@playwright/test/reporter';
|
||||
*
|
||||
* class MyReporter implements Reporter {
|
||||
* private _suite;
|
||||
*
|
||||
* onBegin(config, suite) {
|
||||
* this._suite = suite;
|
||||
* }
|
||||
*
|
||||
* onEnd(result) {
|
||||
* console.log(`Finished the run with ${this._suite.attachments.length} global attachments!`);
|
||||
* }
|
||||
* }
|
||||
* export default MyReporter;
|
||||
* ```
|
||||
*
|
||||
* Finally, specify `globalSetup` in the configuration file and `reporter`:
|
||||
*
|
||||
* ```ts
|
||||
* // playwright.config.ts
|
||||
* import { PlaywrightTestConfig } from '@playwright/test';
|
||||
*
|
||||
* const config: PlaywrightTestConfig = {
|
||||
* globalSetup: require.resolve('./global-setup'),
|
||||
* reporter: require.resolve('./my-awesome-reporter'),
|
||||
* };
|
||||
* export default config;
|
||||
* ```
|
||||
*
|
||||
* See [`TestInfo`](https://playwright.dev/docs/api/class-testinfo) for related attachment functionality scoped to the test-level.
|
||||
*/
|
||||
export interface GlobalInfo {
|
||||
/**
|
||||
* The list of files or buffers attached to the overall test run. Some reporters show global attachments.
|
||||
*
|
||||
* To add an attachment, use
|
||||
* [globalInfo.attach(name[, options])](https://playwright.dev/docs/api/class-globalinfo#global-info-attach). See
|
||||
* [testInfo.attachments](https://playwright.dev/docs/api/class-testinfo#test-info-attachments) if you are looking for
|
||||
* test-scoped attachments.
|
||||
*/
|
||||
attachments(): { name: string, path?: string, body?: Buffer, contentType: string }[];
|
||||
/**
|
||||
* Attach a value or a file from disk to the overall test run. Some reporters show global attachments. Either `path` or
|
||||
* `body` must be specified, but not both.
|
||||
*
|
||||
* See [testInfo.attach(name[, options])](https://playwright.dev/docs/api/class-testinfo#test-info-attach) if you are
|
||||
* looking for test-scoped attachments.
|
||||
*
|
||||
* > NOTE: [globalInfo.attach(name[, options])](https://playwright.dev/docs/api/class-globalinfo#global-info-attach)
|
||||
* automatically takes care of copying attached files to a location that is accessible to reporters. You can safely remove
|
||||
* the attachment after awaiting the attach call.
|
||||
* @param name
|
||||
* @param options
|
||||
*/
|
||||
attach(name: string, options?: { contentType?: string, path?: string, body?: string | Buffer }): Promise<void>;
|
||||
}
|
||||
|
||||
interface SuiteFunction {
|
||||
(title: string, callback: () => void): void;
|
||||
}
|
||||
@ -3654,6 +3587,122 @@ interface ScreenshotAssertions {
|
||||
}): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* `GlobalInfo` contains information on the overall test run. The information spans projects and tests. Some reporters show
|
||||
* global info.
|
||||
*
|
||||
* You can write to GlobalInfo via your Global Setup hook, and read from it in a [Custom Reporter](https://playwright.dev/docs/test-reporters):
|
||||
*
|
||||
* ```ts
|
||||
* // global-setup.ts
|
||||
* import { chromium, FullConfig, GlobalInfo } from '@playwright/test';
|
||||
*
|
||||
* async function globalSetup(config: FullConfig, info: GlobalInfo) {
|
||||
* await info.attach('agent.config.txt', { path: './agent.config.txt' });
|
||||
* }
|
||||
*
|
||||
* export default globalSetup;
|
||||
* ```
|
||||
*
|
||||
* Access the attachments from the Root Suite in the Reporter:
|
||||
*
|
||||
* ```ts
|
||||
* // my-awesome-reporter.ts
|
||||
* import { Reporter } from '@playwright/test/reporter';
|
||||
*
|
||||
* class MyReporter implements Reporter {
|
||||
* private _suite;
|
||||
*
|
||||
* onBegin(config, suite) {
|
||||
* this._suite = suite;
|
||||
* }
|
||||
*
|
||||
* onEnd(result) {
|
||||
* console.log(`Finished the run with ${this._suite.attachments.length} global attachments!`);
|
||||
* }
|
||||
* }
|
||||
* export default MyReporter;
|
||||
* ```
|
||||
*
|
||||
* Finally, specify `globalSetup` in the configuration file and `reporter`:
|
||||
*
|
||||
* ```ts
|
||||
* // playwright.config.ts
|
||||
* import { PlaywrightTestConfig } from '@playwright/test';
|
||||
*
|
||||
* const config: PlaywrightTestConfig = {
|
||||
* globalSetup: require.resolve('./global-setup'),
|
||||
* reporter: require.resolve('./my-awesome-reporter'),
|
||||
* };
|
||||
* export default config;
|
||||
* ```
|
||||
*
|
||||
* See [`TestInfo`](https://playwright.dev/docs/api/class-testinfo) for related attachment functionality scoped to the test-level.
|
||||
*/
|
||||
export interface GlobalInfo {
|
||||
/**
|
||||
* The list of files or buffers attached to the overall test run. Some reporters show global attachments.
|
||||
*
|
||||
* To add an attachment, use
|
||||
* [globalInfo.attach(name[, options])](https://playwright.dev/docs/api/class-globalinfo#global-info-attach). See
|
||||
* [testInfo.attachments](https://playwright.dev/docs/api/class-testinfo#test-info-attachments) if you are looking for
|
||||
* test-scoped attachments.
|
||||
*/
|
||||
attachments(): Array<{
|
||||
/**
|
||||
* Attachment name.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Content type of this attachment to properly present in the report, for example `'application/json'` or `'image/png'`.
|
||||
*/
|
||||
contentType: string;
|
||||
|
||||
/**
|
||||
* Optional path on the filesystem to the attached file.
|
||||
*/
|
||||
path?: string;
|
||||
|
||||
/**
|
||||
* Optional attachment body used instead of a file.
|
||||
*/
|
||||
body?: Buffer;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Attach a value or a file from disk to the overall test run. Some reporters show global attachments. Either `path` or
|
||||
* `body` must be specified, but not both.
|
||||
*
|
||||
* See [testInfo.attach(name[, options])](https://playwright.dev/docs/api/class-testinfo#test-info-attach) if you are
|
||||
* looking for test-scoped attachments.
|
||||
*
|
||||
* > NOTE: [globalInfo.attach(name[, options])](https://playwright.dev/docs/api/class-globalinfo#global-info-attach)
|
||||
* automatically takes care of copying attached files to a location that is accessible to reporters. You can safely remove
|
||||
* the attachment after awaiting the attach call.
|
||||
* @param name Attachment name.
|
||||
* @param options
|
||||
*/
|
||||
attach(name: string, options?: {
|
||||
/**
|
||||
* Attachment body. Mutually exclusive with `path`.
|
||||
*/
|
||||
body?: string|Buffer;
|
||||
|
||||
/**
|
||||
* Optional content type of this attachment to properly present in the report, for example `'application/json'` or
|
||||
* `'image/png'`. If omitted, content type is inferred based on the `path`, or defaults to `text/plain` for [string]
|
||||
* attachments and `application/octet-stream` for [Buffer] attachments.
|
||||
*/
|
||||
contentType?: string;
|
||||
|
||||
/**
|
||||
* Path on the filesystem to the attached file. Mutually exclusive with `body`.
|
||||
*/
|
||||
path?: string;
|
||||
}): Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information about an error thrown during test execution.
|
||||
*/
|
||||
|
||||
207
tests/config/experimental.d.ts
vendored
207
tests/config/experimental.d.ts
vendored
@ -17711,14 +17711,25 @@ export interface TestInfo {
|
||||
* > NOTE: [testInfo.attach(name[, options])](https://playwright.dev/docs/api/class-testinfo#test-info-attach)
|
||||
* automatically takes care of copying attached files to a location that is accessible to reporters. You can safely remove
|
||||
* the attachment after awaiting the attach call.
|
||||
* @param name
|
||||
* @param name Attachment name.
|
||||
* @param options
|
||||
*/
|
||||
attach(name: string, options?: {
|
||||
/**
|
||||
* Attachment body. Mutually exclusive with `path`.
|
||||
*/
|
||||
body?: string|Buffer;
|
||||
|
||||
/**
|
||||
* Content type of this attachment to properly present in the report, for example `'application/json'` or `'image/png'`. If
|
||||
* omitted, content type is inferred based on the `path`, or defaults to `text/plain` for [string] attachments and
|
||||
* `application/octet-stream` for [Buffer] attachments.
|
||||
*/
|
||||
contentType?: string;
|
||||
|
||||
/**
|
||||
* Path on the filesystem to the attached file. Mutually exclusive with `body`.
|
||||
*/
|
||||
path?: string;
|
||||
}): Promise<void>;
|
||||
|
||||
@ -17980,84 +17991,6 @@ export interface TestInfo {
|
||||
*/
|
||||
workerIndex: number;}
|
||||
|
||||
/**
|
||||
* `GlobalInfo` contains information on the overall test run. The information spans projects and tests. Some reporters show
|
||||
* global info.
|
||||
*
|
||||
* You can write to GlobalInfo via your Global Setup hook, and read from it in a [Custom Reporter](https://playwright.dev/docs/test-reporters):
|
||||
*
|
||||
* ```ts
|
||||
* // global-setup.ts
|
||||
* import { chromium, FullConfig, GlobalInfo } from '@playwright/test';
|
||||
*
|
||||
* async function globalSetup(config: FullConfig, info: GlobalInfo) {
|
||||
* await info.attach('agent.config.txt', { path: './agent.config.txt' });
|
||||
* }
|
||||
*
|
||||
* export default globalSetup;
|
||||
* ```
|
||||
*
|
||||
* Access the attachments from the Root Suite in the Reporter:
|
||||
*
|
||||
* ```ts
|
||||
* // my-awesome-reporter.ts
|
||||
* import { Reporter } from '@playwright/test/reporter';
|
||||
*
|
||||
* class MyReporter implements Reporter {
|
||||
* private _suite;
|
||||
*
|
||||
* onBegin(config, suite) {
|
||||
* this._suite = suite;
|
||||
* }
|
||||
*
|
||||
* onEnd(result) {
|
||||
* console.log(`Finished the run with ${this._suite.attachments.length} global attachments!`);
|
||||
* }
|
||||
* }
|
||||
* export default MyReporter;
|
||||
* ```
|
||||
*
|
||||
* Finally, specify `globalSetup` in the configuration file and `reporter`:
|
||||
*
|
||||
* ```ts
|
||||
* // playwright.config.ts
|
||||
* import { PlaywrightTestConfig } from '@playwright/test';
|
||||
*
|
||||
* const config: PlaywrightTestConfig = {
|
||||
* globalSetup: require.resolve('./global-setup'),
|
||||
* reporter: require.resolve('./my-awesome-reporter'),
|
||||
* };
|
||||
* export default config;
|
||||
* ```
|
||||
*
|
||||
* See [`TestInfo`](https://playwright.dev/docs/api/class-testinfo) for related attachment functionality scoped to the test-level.
|
||||
*/
|
||||
export interface GlobalInfo {
|
||||
/**
|
||||
* The list of files or buffers attached to the overall test run. Some reporters show global attachments.
|
||||
*
|
||||
* To add an attachment, use
|
||||
* [globalInfo.attach(name[, options])](https://playwright.dev/docs/api/class-globalinfo#global-info-attach). See
|
||||
* [testInfo.attachments](https://playwright.dev/docs/api/class-testinfo#test-info-attachments) if you are looking for
|
||||
* test-scoped attachments.
|
||||
*/
|
||||
attachments(): { name: string, path?: string, body?: Buffer, contentType: string }[];
|
||||
/**
|
||||
* Attach a value or a file from disk to the overall test run. Some reporters show global attachments. Either `path` or
|
||||
* `body` must be specified, but not both.
|
||||
*
|
||||
* See [testInfo.attach(name[, options])](https://playwright.dev/docs/api/class-testinfo#test-info-attach) if you are
|
||||
* looking for test-scoped attachments.
|
||||
*
|
||||
* > NOTE: [globalInfo.attach(name[, options])](https://playwright.dev/docs/api/class-globalinfo#global-info-attach)
|
||||
* automatically takes care of copying attached files to a location that is accessible to reporters. You can safely remove
|
||||
* the attachment after awaiting the attach call.
|
||||
* @param name
|
||||
* @param options
|
||||
*/
|
||||
attach(name: string, options?: { contentType?: string, path?: string, body?: string | Buffer }): Promise<void>;
|
||||
}
|
||||
|
||||
interface SuiteFunction {
|
||||
(title: string, callback: () => void): void;
|
||||
}
|
||||
@ -20086,6 +20019,122 @@ interface ScreenshotAssertions {
|
||||
}): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* `GlobalInfo` contains information on the overall test run. The information spans projects and tests. Some reporters show
|
||||
* global info.
|
||||
*
|
||||
* You can write to GlobalInfo via your Global Setup hook, and read from it in a [Custom Reporter](https://playwright.dev/docs/test-reporters):
|
||||
*
|
||||
* ```ts
|
||||
* // global-setup.ts
|
||||
* import { chromium, FullConfig, GlobalInfo } from '@playwright/test';
|
||||
*
|
||||
* async function globalSetup(config: FullConfig, info: GlobalInfo) {
|
||||
* await info.attach('agent.config.txt', { path: './agent.config.txt' });
|
||||
* }
|
||||
*
|
||||
* export default globalSetup;
|
||||
* ```
|
||||
*
|
||||
* Access the attachments from the Root Suite in the Reporter:
|
||||
*
|
||||
* ```ts
|
||||
* // my-awesome-reporter.ts
|
||||
* import { Reporter } from '@playwright/test/reporter';
|
||||
*
|
||||
* class MyReporter implements Reporter {
|
||||
* private _suite;
|
||||
*
|
||||
* onBegin(config, suite) {
|
||||
* this._suite = suite;
|
||||
* }
|
||||
*
|
||||
* onEnd(result) {
|
||||
* console.log(`Finished the run with ${this._suite.attachments.length} global attachments!`);
|
||||
* }
|
||||
* }
|
||||
* export default MyReporter;
|
||||
* ```
|
||||
*
|
||||
* Finally, specify `globalSetup` in the configuration file and `reporter`:
|
||||
*
|
||||
* ```ts
|
||||
* // playwright.config.ts
|
||||
* import { PlaywrightTestConfig } from '@playwright/test';
|
||||
*
|
||||
* const config: PlaywrightTestConfig = {
|
||||
* globalSetup: require.resolve('./global-setup'),
|
||||
* reporter: require.resolve('./my-awesome-reporter'),
|
||||
* };
|
||||
* export default config;
|
||||
* ```
|
||||
*
|
||||
* See [`TestInfo`](https://playwright.dev/docs/api/class-testinfo) for related attachment functionality scoped to the test-level.
|
||||
*/
|
||||
export interface GlobalInfo {
|
||||
/**
|
||||
* The list of files or buffers attached to the overall test run. Some reporters show global attachments.
|
||||
*
|
||||
* To add an attachment, use
|
||||
* [globalInfo.attach(name[, options])](https://playwright.dev/docs/api/class-globalinfo#global-info-attach). See
|
||||
* [testInfo.attachments](https://playwright.dev/docs/api/class-testinfo#test-info-attachments) if you are looking for
|
||||
* test-scoped attachments.
|
||||
*/
|
||||
attachments(): Array<{
|
||||
/**
|
||||
* Attachment name.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* Content type of this attachment to properly present in the report, for example `'application/json'` or `'image/png'`.
|
||||
*/
|
||||
contentType: string;
|
||||
|
||||
/**
|
||||
* Optional path on the filesystem to the attached file.
|
||||
*/
|
||||
path?: string;
|
||||
|
||||
/**
|
||||
* Optional attachment body used instead of a file.
|
||||
*/
|
||||
body?: Buffer;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Attach a value or a file from disk to the overall test run. Some reporters show global attachments. Either `path` or
|
||||
* `body` must be specified, but not both.
|
||||
*
|
||||
* See [testInfo.attach(name[, options])](https://playwright.dev/docs/api/class-testinfo#test-info-attach) if you are
|
||||
* looking for test-scoped attachments.
|
||||
*
|
||||
* > NOTE: [globalInfo.attach(name[, options])](https://playwright.dev/docs/api/class-globalinfo#global-info-attach)
|
||||
* automatically takes care of copying attached files to a location that is accessible to reporters. You can safely remove
|
||||
* the attachment after awaiting the attach call.
|
||||
* @param name Attachment name.
|
||||
* @param options
|
||||
*/
|
||||
attach(name: string, options?: {
|
||||
/**
|
||||
* Attachment body. Mutually exclusive with `path`.
|
||||
*/
|
||||
body?: string|Buffer;
|
||||
|
||||
/**
|
||||
* Optional content type of this attachment to properly present in the report, for example `'application/json'` or
|
||||
* `'image/png'`. If omitted, content type is inferred based on the `path`, or defaults to `text/plain` for [string]
|
||||
* attachments and `application/octet-stream` for [Buffer] attachments.
|
||||
*/
|
||||
contentType?: string;
|
||||
|
||||
/**
|
||||
* Path on the filesystem to the attached file. Mutually exclusive with `body`.
|
||||
*/
|
||||
path?: string;
|
||||
}): Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information about an error thrown during test execution.
|
||||
*/
|
||||
|
||||
5
utils/generate_types/overrides-test.d.ts
vendored
5
utils/generate_types/overrides-test.d.ts
vendored
@ -150,11 +150,6 @@ export interface TestInfo {
|
||||
status?: TestStatus;
|
||||
}
|
||||
|
||||
export interface GlobalInfo {
|
||||
attachments(): { name: string, path?: string, body?: Buffer, contentType: string }[];
|
||||
attach(name: string, options?: { contentType?: string, path?: string, body?: string | Buffer }): Promise<void>;
|
||||
}
|
||||
|
||||
interface SuiteFunction {
|
||||
(title: string, callback: () => void): void;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user