Skip to content

Commit eadbfc4

Browse files
committed
PRO-14812 fix: skipped tests should be failed in Playwright
1 parent 835a690 commit eadbfc4

5 files changed

Lines changed: 18 additions & 15 deletions

File tree

autotests/pageObjects/pages/Main.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,17 @@ export class Main extends Page<CustomPageParams> {
7070
await this.waitForDomContentLoaded();
7171

7272
await waitForAllRequestsComplete(
73+
// eslint-disable-next-line complexity
7374
({url}) => {
7475
if (
7576
url.startsWith('https://assets.msn.com/') ||
7677
url.startsWith('https://www.bing.com/ipv6test/') ||
7778
url.startsWith('https://www2.bing.com/ipv6test/') ||
7879
url.startsWith('https://browser.events.data.msn.com/') ||
7980
url.startsWith('https://img-s-msn-com.akamaized.net/') ||
81+
url.startsWith('https://login.microsoftonline.com/') ||
8082
url.startsWith('https://rewards.bing.com/widget/') ||
83+
url.startsWith('https://scripts.clarity.ms/') ||
8184
url.startsWith('https://th.bing.com/th?id=') ||
8285
url.startsWith('https://www.bing.com/th?id=')
8386
) {
@@ -86,7 +89,10 @@ export class Main extends Page<CustomPageParams> {
8689

8790
return true;
8891
},
89-
{maxIntervalBetweenRequestsInMs: this.maxIntervalBetweenRequestsInMs, timeout: 8_000},
92+
{
93+
maxIntervalBetweenRequestsInMs: this.maxIntervalBetweenRequestsInMs,
94+
timeout: Main.navigationTimeout,
95+
},
9096
);
9197
}
9298
}

autotests/tests/main/exists.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {assertFunctionThrows, getDocumentUrl} from 'e2ed/utils';
2020
import type {Url} from 'e2ed/types';
2121

2222
// eslint-disable-next-line max-statements
23-
test('exists', {meta: {testId: '1'}, testIdleTimeout: 10_000, testTimeout: 15_000}, async () => {
23+
test('exists', {meta: {testId: '1'}, testIdleTimeout: 10_000, testTimeout: 20_000}, async () => {
2424
const language = 'en';
2525
const searchQuery = 'foo';
2626
const testScrollValue = 200;

src/utils/test/afterTest.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import {TestRunStatus} from '../../constants/internal';
12
import {getClearPage} from '../../context/clearPage';
23

3-
import {registerEndTestRunEvent} from '../events';
4+
import {getTestRunEvent, registerEndTestRunEvent} from '../events';
45
import {generalLog, writeLogsToFile} from '../generalLog';
56

67
import type {EndTestRunEvent, UtcTimeInMs} from '../../types/internal';
@@ -27,5 +28,12 @@ export const afterTest = async (options: Options): Promise<void> => {
2728
await writeLogsToFile();
2829

2930
throw error;
31+
} finally {
32+
const testRunEvent = getTestRunEvent(options.runId);
33+
34+
if (testRunEvent.status === TestRunStatus.Skipped) {
35+
// eslint-disable-next-line no-unsafe-finally
36+
throw new Error(`Skipped test "${testRunEvent.name}" should be failed in Playwright`);
37+
}
3038
}
3139
};

src/utils/test/beforeTest.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ export const beforeTest = ({
7777
const {onlog, reject, testFnWithReject} = getTestFnAndReject({
7878
isSkipped,
7979
runId,
80-
skipReason,
8180
testFn,
8281
testIdleTimeout,
8382
testTimeout,

src/utils/test/getTestFnAndReject.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ 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-
1311
type Options = Readonly<{
1412
isSkipped: boolean;
1513
runId: RunId;
16-
skipReason: string | undefined;
1714
testFn: TestFn;
1815
testIdleTimeout: number;
1916
testTimeout: number;
@@ -29,7 +26,6 @@ type Return = Readonly<{onlog: Onlog; reject: RejectTestRun; testFnWithReject: T
2926
export const getTestFnAndReject = ({
3027
isSkipped,
3128
runId,
32-
skipReason,
3329
testFn,
3430
testIdleTimeout,
3531
testTimeout,
@@ -38,13 +34,7 @@ export const getTestFnAndReject = ({
3834
return {
3935
onlog: () => undefined,
4036
reject: () => undefined,
41-
testFnWithReject: () => {
42-
try {
43-
playwrightTest.skip(true, skipReason);
44-
} catch {}
45-
46-
return RESOLVED_PROMISE;
47-
},
37+
testFnWithReject: () => RESOLVED_PROMISE,
4838
};
4939
}
5040

0 commit comments

Comments
 (0)