Skip to content

Commit e02800d

Browse files
committed
PRO-14812 fix: really skip skipped tests in Playwright
1 parent ee8b0d9 commit e02800d

File tree

6 files changed

+37
-22
lines changed

6 files changed

+37
-22
lines changed

src/utils/report/client/groupLogEvents.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {LogEventType} from '../../../constants/internal';
1+
import {LogEventStatus, LogEventType} from '../../../constants/internal';
22

33
import type {LogEvent, LogEventWithChildren} from '../../../types/internal';
44

@@ -16,14 +16,18 @@ export const groupLogEvents = (logEvents: readonly LogEvent[]): readonly LogEven
1616
LogEventType.InternalAssert,
1717
];
1818

19+
const isTopLevelEvent = (logEvent: LogEvent): boolean =>
20+
topLevelTypes.includes(logEvent.type) ||
21+
logEvent.payload?.logEventStatus === LogEventStatus.Failed;
22+
1923
const result: LogEventWithChildren[] = [];
2024

2125
for (const logEvent of logEvents) {
2226
const last = result.at(-1);
2327
const newEvent: LogEventWithChildren = {children: [], ...logEvent};
2428

25-
if (topLevelTypes.includes(logEvent.type)) {
26-
if (last && !topLevelTypes.includes(last.type)) {
29+
if (isTopLevelEvent(logEvent)) {
30+
if (last && !isTopLevelEvent(last)) {
2731
const firstTopLevel: LogEventWithChildren = {
2832
children: [...result],
2933
message: 'Initialization',
@@ -38,7 +42,7 @@ export const groupLogEvents = (logEvents: readonly LogEvent[]): readonly LogEven
3842
}
3943

4044
result.push(newEvent);
41-
} else if (last && topLevelTypes.includes(last.type)) {
45+
} else if (last && isTopLevelEvent(last)) {
4246
(last.children as LogEventWithChildren[]).push(newEvent);
4347
} else {
4448
result.push(newEvent);

src/utils/report/client/render/TestRunDescription.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const TestRunDescription: JSX.Component<Props> = ({fullTestRun}) => {
3131
const valueWithLinks = parseMarkdownLinks`${value}`;
3232
const metaHtml = (
3333
<>
34-
<dt class="test-description__term">{key}</dt>
34+
<dt class="test-description__term">{key}</dt>{' '}
3535
<dd class="test-description__definition">{valueWithLinks}</dd>
3636
</>
3737
);
@@ -49,7 +49,7 @@ export const TestRunDescription: JSX.Component<Props> = ({fullTestRun}) => {
4949

5050
traceHtml = (
5151
<>
52-
<dt class="test-description__term">{traceLabel}</dt>
52+
<dt class="test-description__term">{traceLabel}</dt>{' '}
5353
<dd class="test-description__definition">
5454
<a href={traceUrl} download={traceName} aria-label={traceLabel}>
5555
{traceName}
@@ -63,11 +63,11 @@ export const TestRunDescription: JSX.Component<Props> = ({fullTestRun}) => {
6363
<dl class="test-description" aria-label="Test meta data">
6464
<List elements={metaHtmls} />
6565
{traceHtml}
66-
<dt class="test-description__term">Date</dt>
66+
<dt class="test-description__term">Date</dt>{' '}
6767
<dd class="test-description__definition">
6868
<DatesInterval endTimeInMs={endTimeInMs} startTimeInMs={startTimeInMs} />
6969
</dd>
70-
<dt class="test-description__term">Duration</dt>
70+
<dt class="test-description__term">Duration</dt>{' '}
7171
<dd class="test-description__definition">
7272
<Duration durationInMs={endTimeInMs - startTimeInMs} />
7373
</dd>

src/utils/test/beforeTest.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {getTestFnAndReject} from './getTestFnAndReject';
2121

2222
import type {TestRunEvent, TestUnit, UtcTimeInMs} from '../../types/internal';
2323

24-
import {test} from '@playwright/test';
24+
import {test as playwrightTest} from '@playwright/test';
2525

2626
const additionToPlaywrightTestTimeout = 500;
2727

@@ -59,7 +59,9 @@ export const beforeTest = ({
5959
const testTimeout =
6060
IS_DEBUG || isUiMode ? MAX_TIMEOUT_IN_MS : (options.testTimeout ?? testTimeoutFromConfig);
6161

62-
test.setTimeout(testTimeout + additionToPlaywrightTestTimeout + (Date.now() - startTimeInMs));
62+
playwrightTest.setTimeout(
63+
testTimeout + additionToPlaywrightTestTimeout + (Date.now() - startTimeInMs),
64+
);
6365

6466
setTestIdleTimeout(testIdleTimeout);
6567
setTestTimeout(testTimeout);
@@ -75,6 +77,7 @@ export const beforeTest = ({
7577
const {onlog, reject, testFnWithReject} = getTestFnAndReject({
7678
isSkipped,
7779
runId,
80+
skipReason,
7881
testFn,
7982
testIdleTimeout,
8083
testTimeout,

src/utils/test/getTestFnAndReject.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,19 @@ import {getPromiseWithResolveAndReject} from '../promise';
88

99
import type {Onlog, RejectTestRun, RunId, TestFn, Void} from '../../types/internal';
1010

11+
import {test as playwrightTest} from '@playwright/test';
12+
1113
type Options = Readonly<{
1214
isSkipped: boolean;
1315
runId: RunId;
16+
skipReason: string | undefined;
1417
testFn: TestFn;
1518
testIdleTimeout: number;
1619
testTimeout: number;
1720
}>;
1821

1922
type Return = Readonly<{onlog: Onlog; reject: RejectTestRun; testFnWithReject: TestFn}>;
2023

21-
const skippedTestFnAndReject: Return = {
22-
onlog: () => undefined,
23-
reject: () => undefined,
24-
testFnWithReject: () => RESOLVED_PROMISE,
25-
};
26-
2724
/**
2825
* Get test function with execution timeout, idle timeout, reject and onlog functions,
2926
* by isSkipped flag, test function, runId, test execution timeout and test idle timeouts.
@@ -32,12 +29,23 @@ const skippedTestFnAndReject: Return = {
3229
export const getTestFnAndReject = ({
3330
isSkipped,
3431
runId,
32+
skipReason,
3533
testFn,
3634
testIdleTimeout,
3735
testTimeout,
3836
}: Options): Return => {
3937
if (isSkipped) {
40-
return skippedTestFnAndReject;
38+
return {
39+
onlog: () => undefined,
40+
reject: () => undefined,
41+
testFnWithReject: () => {
42+
try {
43+
playwrightTest.skip(true, skipReason);
44+
} catch {}
45+
46+
return RESOLVED_PROMISE;
47+
},
48+
};
4149
}
4250

4351
const {

src/utils/test/waitBeforeRetry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {getPreviousRunId} from './getPreviousRunId';
77

88
import type {FullTestRun, RunId, TestStaticOptions} from '../../types/internal';
99

10-
import {test} from '@playwright/test';
10+
import {test as playwrightTest} from '@playwright/test';
1111

1212
const additionToTimeout = 10_000;
1313

@@ -57,7 +57,7 @@ export const waitBeforeRetry = async (
5757
return;
5858
}
5959

60-
test.setTimeout(timeoutInMs + additionToTimeout);
60+
playwrightTest.setTimeout(timeoutInMs + additionToTimeout);
6161

6262
const timeoutObject = setInterval(() => {
6363
void writeLogEventTime();

styles/report.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ a:visited {
553553
color: var(--subtitle-color);
554554
}
555555
.test-description__term::after {
556-
content: ':\00a0';
556+
content: ':';
557557
}
558558
.test-description__definition {
559559
margin: 0;
@@ -1206,7 +1206,7 @@ a:visited {
12061206
overflow: hidden;
12071207
border-radius: var(--main-radius);
12081208
background: var(--secondary-bg-color);
1209-
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
1209+
box-shadow: 0 0 10px rgb(0, 0, 0, 0.3);
12101210
}
12111211
.screenshot-dialog[open] {
12121212
display: flex;
@@ -1226,7 +1226,7 @@ a:visited {
12261226
text-overflow: ellipsis;
12271227
}
12281228
.screenshot-dialog::backdrop {
1229-
background: rgba(0, 0, 0, 0.5);
1229+
background: rgb(0, 0, 0, 0.5);
12301230
}
12311231
.screenshot-dialog__main {
12321232
padding: var(--padding);

0 commit comments

Comments
 (0)