Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/playwright/src/reporters/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...test.annotations].filter(a => a.type === 'warning');
// const warnings = [...result.annotations, ...test.annotations].filter(a => a.type === 'warning');
const resultLines: string[] = [];
const errors = formatResultFailure(screen, test, result, ' ');
if (!errors.length)
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 10 additions & 9 deletions packages/playwright/src/worker/workerMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,16 +435,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();
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/playwright-test/reporter-base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright-test/warnings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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': `
Expand Down
Loading