Update ConsoleMessage.type() to return specific string literals

Co-authored-by: yury-s <9798949+yury-s@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-05-22 17:08:07 +00:00
parent 2f61033732
commit f0203864d1
3 changed files with 142 additions and 140 deletions

View File

@ -16253,6 +16253,75 @@ export const _android: Android;
export const _bidiChromium: BrowserType;
export const _bidiFirefox: BrowserType;
/**
* [ConsoleMessage](https://playwright.dev/docs/api/class-consolemessage) objects are dispatched by page via the
* [page.on('console')](https://playwright.dev/docs/api/class-page#page-event-console) event. For each console message
* logged in the page there will be corresponding event in the Playwright context.
*
* ```js
* // Listen for all console logs
* page.on('console', msg => console.log(msg.text()));
*
* // Listen for all console events and handle errors
* page.on('console', msg => {
* if (msg.type() === 'error')
* console.log(`Error text: "${msg.text()}"`);
* });
*
* // Get the next console log
* const msgPromise = page.waitForEvent('console');
* await page.evaluate(() => {
* console.log('hello', 42, { foo: 'bar' }); // Issue console.log inside the page
* });
* const msg = await msgPromise;
*
* // Deconstruct console log arguments
* await msg.args()[0].jsonValue(); // hello
* await msg.args()[1].jsonValue(); // 42
* ```
*
*/
export interface ConsoleMessage {
/**
* One of the following values: `'log'`, `'debug'`, `'info'`, `'error'`, `'warning'`, `'dir'`, `'dirxml'`, `'table'`,
* `'trace'`, `'clear'`, `'startGroup'`, `'startGroupCollapsed'`, `'endGroup'`, `'assert'`, `'profile'`,
* `'profileEnd'`, `'count'`, `'timeEnd'`.
*/
type(): 'log'|'debug'|'info'|'error'|'warning'|'dir'|'dirxml'|'table'|'trace'|'clear'|'startGroup'|'startGroupCollapsed'|'endGroup'|'assert'|'profile'|'profileEnd'|'count'|'timeEnd';
/**
* List of arguments passed to a `console` function call. See also
* [page.on('console')](https://playwright.dev/docs/api/class-page#page-event-console).
*/
args(): Array<JSHandle>;
location(): {
/**
* URL of the resource.
*/
url: string;
/**
* 0-based line number in the resource.
*/
lineNumber: number;
/**
* 0-based column number in the resource.
*/
columnNumber: number;
};
/**
* The page that produced this console message, if any.
*/
page(): null|Page;
/**
* The text of the console message.
*/
text(): string;
}
// This is required to not export everything by default. See https://github.com/Microsoft/TypeScript/issues/19545#issuecomment-340490459
export {};
@ -18771,76 +18840,6 @@ export interface Clock {
setSystemTime(time: number|string|Date): Promise<void>;
}
/**
* [ConsoleMessage](https://playwright.dev/docs/api/class-consolemessage) objects are dispatched by page via the
* [page.on('console')](https://playwright.dev/docs/api/class-page#page-event-console) event. For each console message
* logged in the page there will be corresponding event in the Playwright context.
*
* ```js
* // Listen for all console logs
* page.on('console', msg => console.log(msg.text()));
*
* // Listen for all console events and handle errors
* page.on('console', msg => {
* if (msg.type() === 'error')
* console.log(`Error text: "${msg.text()}"`);
* });
*
* // Get the next console log
* const msgPromise = page.waitForEvent('console');
* await page.evaluate(() => {
* console.log('hello', 42, { foo: 'bar' }); // Issue console.log inside the page
* });
* const msg = await msgPromise;
*
* // Deconstruct console log arguments
* await msg.args()[0].jsonValue(); // hello
* await msg.args()[1].jsonValue(); // 42
* ```
*
*/
export interface ConsoleMessage {
/**
* List of arguments passed to a `console` function call. See also
* [page.on('console')](https://playwright.dev/docs/api/class-page#page-event-console).
*/
args(): Array<JSHandle>;
location(): {
/**
* URL of the resource.
*/
url: string;
/**
* 0-based line number in the resource.
*/
lineNumber: number;
/**
* 0-based column number in the resource.
*/
columnNumber: number;
};
/**
* The page that produced this console message, if any.
*/
page(): null|Page;
/**
* The text of the console message.
*/
text(): string;
/**
* One of the following values: `'log'`, `'debug'`, `'info'`, `'error'`, `'warning'`, `'dir'`, `'dirxml'`, `'table'`,
* `'trace'`, `'clear'`, `'startGroup'`, `'startGroupCollapsed'`, `'endGroup'`, `'assert'`, `'profile'`,
* `'profileEnd'`, `'count'`, `'timeEnd'`.
*/
type(): string;
}
/**
* Coverage gathers information about parts of JavaScript and CSS that were used by the page.
*

View File

@ -16253,6 +16253,75 @@ export const _android: Android;
export const _bidiChromium: BrowserType;
export const _bidiFirefox: BrowserType;
/**
* [ConsoleMessage](https://playwright.dev/docs/api/class-consolemessage) objects are dispatched by page via the
* [page.on('console')](https://playwright.dev/docs/api/class-page#page-event-console) event. For each console message
* logged in the page there will be corresponding event in the Playwright context.
*
* ```js
* // Listen for all console logs
* page.on('console', msg => console.log(msg.text()));
*
* // Listen for all console events and handle errors
* page.on('console', msg => {
* if (msg.type() === 'error')
* console.log(`Error text: "${msg.text()}"`);
* });
*
* // Get the next console log
* const msgPromise = page.waitForEvent('console');
* await page.evaluate(() => {
* console.log('hello', 42, { foo: 'bar' }); // Issue console.log inside the page
* });
* const msg = await msgPromise;
*
* // Deconstruct console log arguments
* await msg.args()[0].jsonValue(); // hello
* await msg.args()[1].jsonValue(); // 42
* ```
*
*/
export interface ConsoleMessage {
/**
* One of the following values: `'log'`, `'debug'`, `'info'`, `'error'`, `'warning'`, `'dir'`, `'dirxml'`, `'table'`,
* `'trace'`, `'clear'`, `'startGroup'`, `'startGroupCollapsed'`, `'endGroup'`, `'assert'`, `'profile'`,
* `'profileEnd'`, `'count'`, `'timeEnd'`.
*/
type(): 'log'|'debug'|'info'|'error'|'warning'|'dir'|'dirxml'|'table'|'trace'|'clear'|'startGroup'|'startGroupCollapsed'|'endGroup'|'assert'|'profile'|'profileEnd'|'count'|'timeEnd';
/**
* List of arguments passed to a `console` function call. See also
* [page.on('console')](https://playwright.dev/docs/api/class-page#page-event-console).
*/
args(): Array<JSHandle>;
location(): {
/**
* URL of the resource.
*/
url: string;
/**
* 0-based line number in the resource.
*/
lineNumber: number;
/**
* 0-based column number in the resource.
*/
columnNumber: number;
};
/**
* The page that produced this console message, if any.
*/
page(): null|Page;
/**
* The text of the console message.
*/
text(): string;
}
// This is required to not export everything by default. See https://github.com/Microsoft/TypeScript/issues/19545#issuecomment-340490459
export {};
@ -18771,76 +18840,6 @@ export interface Clock {
setSystemTime(time: number|string|Date): Promise<void>;
}
/**
* [ConsoleMessage](https://playwright.dev/docs/api/class-consolemessage) objects are dispatched by page via the
* [page.on('console')](https://playwright.dev/docs/api/class-page#page-event-console) event. For each console message
* logged in the page there will be corresponding event in the Playwright context.
*
* ```js
* // Listen for all console logs
* page.on('console', msg => console.log(msg.text()));
*
* // Listen for all console events and handle errors
* page.on('console', msg => {
* if (msg.type() === 'error')
* console.log(`Error text: "${msg.text()}"`);
* });
*
* // Get the next console log
* const msgPromise = page.waitForEvent('console');
* await page.evaluate(() => {
* console.log('hello', 42, { foo: 'bar' }); // Issue console.log inside the page
* });
* const msg = await msgPromise;
*
* // Deconstruct console log arguments
* await msg.args()[0].jsonValue(); // hello
* await msg.args()[1].jsonValue(); // 42
* ```
*
*/
export interface ConsoleMessage {
/**
* List of arguments passed to a `console` function call. See also
* [page.on('console')](https://playwright.dev/docs/api/class-page#page-event-console).
*/
args(): Array<JSHandle>;
location(): {
/**
* URL of the resource.
*/
url: string;
/**
* 0-based line number in the resource.
*/
lineNumber: number;
/**
* 0-based column number in the resource.
*/
columnNumber: number;
};
/**
* The page that produced this console message, if any.
*/
page(): null|Page;
/**
* The text of the console message.
*/
text(): string;
/**
* One of the following values: `'log'`, `'debug'`, `'info'`, `'error'`, `'warning'`, `'dir'`, `'dirxml'`, `'table'`,
* `'trace'`, `'clear'`, `'startGroup'`, `'startGroupCollapsed'`, `'endGroup'`, `'assert'`, `'profile'`,
* `'profileEnd'`, `'count'`, `'timeEnd'`.
*/
type(): 'log'|'debug'|'info'|'error'|'warning'|'dir'|'dirxml'|'table'|'trace'|'clear'|'startGroup'|'startGroupCollapsed'|'endGroup'|'assert'|'profile'|'profileEnd'|'count'|'timeEnd';
}
/**
* Coverage gathers information about parts of JavaScript and CSS that were used by the page.
*

View File

@ -384,5 +384,9 @@ export const _android: Android;
export const _bidiChromium: BrowserType;
export const _bidiFirefox: BrowserType;
export interface ConsoleMessage {
type(): 'log'|'debug'|'info'|'error'|'warning'|'dir'|'dirxml'|'table'|'trace'|'clear'|'startGroup'|'startGroupCollapsed'|'endGroup'|'assert'|'profile'|'profileEnd'|'count'|'timeEnd';
}
// This is required to not export everything by default. See https://github.com/Microsoft/TypeScript/issues/19545#issuecomment-340490459
export {};