Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: temporarily disable floating promise warning messages v2 (#35603)

Adam Gastineau78600c60f8e9
diff --git a/packages/playwright/src/reporters/base.ts b/packages/playwright/src/reporters/base.ts
index 271b70b275..75807c1b67 100644
--- a/packages/playwright/src/reporters/base.ts
+++ b/packages/playwright/src/reporters/base.ts
@@ -320,7 +320,7 @@ export function formatFailure(screen: Screen, config: FullConfig, test: TestCase
const header = formatTestHeader(screen, config, test, { indent: ' ', index, mode: 'error' });
lines.push(screen.colors.red(header));
for (const result of test.results) {
- const warnings = result.annotations.filter(a => a.type === 'warning');
+ // const warnings = result.annotations.filter(a => a.type === 'warning');
const resultLines: string[] = [];
const errors = formatResultFailure(screen, test, result, ' ');
if (!errors.length)
@@ -330,10 +330,11 @@ export function formatFailure(screen: Screen, config: FullConfig, test: TestCase
resultLines.push(screen.colors.gray(separator(screen, ` Retry #${result.retry}`)));
}
resultLines.push(...errors.map(error => '\n' + error.message));
- if (warnings.length) {
- resultLines.push('');
- resultLines.push(...formatTestWarning(screen, config, warnings));
- }
+ // TODO: 1.53: Actually build annotations
+ // if (warnings.length) {
+ // resultLines.push('');
+ // resultLines.push(...formatTestWarning(screen, config, warnings));
+ // }
for (let i = 0; i < result.attachments.length; ++i) {
const attachment = result.attachments[i];
if (attachment.name.startsWith('_prompt') && attachment.path) {
@@ -376,6 +377,7 @@ export function formatFailure(screen: Screen, config: FullConfig, test: TestCase
return lines.join('\n');
}
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
function formatTestWarning(screen: Screen, config: FullConfig, warnings: TestAnnotation[]): string[] {
warnings.sort((a, b) => {
const aLocationKey = a.location ? `${a.location.file}:${a.location.line}:${a.location.column}` : undefined;
diff --git a/packages/playwright/src/worker/workerMain.ts b/packages/playwright/src/worker/workerMain.ts
index 703bf166e3..5bc042b794 100644
--- a/packages/playwright/src/worker/workerMain.ts
+++ b/packages/playwright/src/worker/workerMain.ts
@@ -433,16 +433,17 @@ export class WorkerMain extends ProcessRunner {
// Only if failed, create warning if any of the async calls were not awaited in various stages.
if (!process.env.PW_DISABLE_FLOATING_PROMISES_WARNING && testInfo._floatingPromiseScope.hasFloatingPromises()) {
+ // TODO: 1.53: Actually build annotations
// Dedupe by location
- const annotationLocations = new Map<string | undefined, Location | undefined>(testInfo._floatingPromiseScope.floatingPromises().map(
- ({ location }) => {
- const locationKey = location ? `${location.file}:${location.line}:${location.column}` : undefined;
- return [locationKey, location];
- }));
-
- testInfo.annotations.push(...[...annotationLocations.values()].map(location => ({
- type: 'warning', description: `This async call was not awaited by the end of the test. This can cause flakiness. It is recommended to run ESLint with "@typescript-eslint/no-floating-promises" to verify.`, location
- })));
+ // const annotationLocations = new Map<string | undefined, Location | undefined>(testInfo._floatingPromiseScope.floatingPromises().map(
+ // ({ location }) => {
+ // const locationKey = location ? `${location.file}:${location.line}:${location.column}` : undefined;
+ // return [locationKey, location];
+ // }));
+
+ // testInfo.annotations.push(...[...annotationLocations.values()].map(location => ({
+ // type: 'warning', description: `This async call was not awaited by the end of the test. This can cause flakiness. It is recommended to run ESLint with "@typescript-eslint/no-floating-promises" to verify.`, location
+ // })));
testInfo._floatingPromiseScope.clear();
}
}
diff --git a/tests/playwright-test/reporter-base.spec.ts b/tests/playwright-test/reporter-base.spec.ts
index 2caecce225..e0af6929fb 100644
--- a/tests/playwright-test/reporter-base.spec.ts
+++ b/tests/playwright-test/reporter-base.spec.ts
@@ -487,7 +487,7 @@ for (const useIntermediateMergeReport of [false, true] as const) {
expect(text).toContain('› passes @baz1 @baz2 (');
});
- test('should show warnings on failing tests', async ({ runInlineTest }) => {
+ test.skip('should show warnings on failing tests', async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.spec.ts': `
import { test, expect } from '@playwright/test';
@@ -504,7 +504,7 @@ for (const useIntermediateMergeReport of [false, true] as const) {
expect(result.output).toContain('Warning: foo');
});
- test('should not show warnings on passing tests', async ({ runInlineTest }) => {
+ test.skip('should not show warnings on passing tests', async ({ runInlineTest }) => {
const result = await runInlineTest({
'a.spec.ts': `
import { test, expect } from '@playwright/test';
@@ -518,7 +518,7 @@ for (const useIntermediateMergeReport of [false, true] as const) {
expect(result.output).not.toContain('Warning: foo');
});
- test('should properly sort warnings', async ({ runInlineTest }) => {
+ test.skip('should properly sort warnings', async ({ runInlineTest }) => {
const result = await runInlineTest({
'external.js': `
import { expect } from '@playwright/test';
diff --git a/tests/playwright-test/warnings.spec.ts b/tests/playwright-test/warnings.spec.ts
index 4b0f9ed812..38dca1dfe6 100644
--- a/tests/playwright-test/warnings.spec.ts
+++ b/tests/playwright-test/warnings.spec.ts
@@ -20,7 +20,7 @@ const description = 'This async call was not awaited by the end of the test. Thi
test.describe.configure({ mode: 'parallel' });
-test.describe('await', () => {
+test.describe.skip('await', () => {
test('should not care about non-API promises', async ({ runInlineTest }) => {
const { exitCode, results } = await runInlineTest({
'a.test.ts': `