mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
fix(console): make format console message w/o args (#26620)
Fixes https://github.com/microsoft/playwright/issues/26600
This commit is contained in:
parent
5646875e5c
commit
65aa062ea1
@ -106,7 +106,7 @@ export const ConsoleTab: React.FunctionComponent<{
|
||||
|
||||
const { browserMessage, browserError, nodeMessage } = entry;
|
||||
if (browserMessage) {
|
||||
const text = browserMessage.args ? format(browserMessage.args) : browserMessage.text;
|
||||
const text = browserMessage.args && browserMessage.args.length ? format(browserMessage.args) : browserMessage.text;
|
||||
const url = browserMessage.location.url;
|
||||
const filename = url ? url.substring(url.lastIndexOf('/') + 1) : '<anonymous>';
|
||||
locationText = `${filename}:${browserMessage.location.lineNumber}`;
|
||||
|
||||
@ -117,13 +117,14 @@ test('should format console messages in page', async ({ runUITest }, testInfo) =
|
||||
'a.spec.ts': `
|
||||
import { test, expect } from '@playwright/test';
|
||||
test('print', async ({ page }) => {
|
||||
await page.evaluate(() => {
|
||||
await page.evaluate(async () => {
|
||||
console.log('Object %O', { a: 1 });
|
||||
console.log('Date %o', new Date());
|
||||
console.log('Regex %o', /a/);
|
||||
console.log('Number %f', -0, 'one', 2);
|
||||
console.log('Download the %cReact DevTools%c for a better development experience: %chttps://fb.me/react-devtools', 'font-weight:bold;color:red;outline:blue', '', 'color: blue; text-decoration: underline');
|
||||
console.log('Array', 'of', 'values');
|
||||
await fetch('http://localhost:9889');
|
||||
});
|
||||
});
|
||||
`,
|
||||
@ -139,6 +140,7 @@ test('should format console messages in page', async ({ runUITest }, testInfo) =
|
||||
'Number 0 one 2',
|
||||
'Download the React DevTools for a better development experience: https://fb.me/react-devtools',
|
||||
'Array of values',
|
||||
'Failed to load resource: net::ERR_CONNECTION_REFUSED',
|
||||
]);
|
||||
|
||||
const label = page.getByText('React DevTools');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user