Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions autotests/pageObjects/pages/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class Main extends Page<CustomPageParams> {
url.startsWith('https://browser.events.data.msn.com/') ||
url.startsWith('https://img-s-msn-com.akamaized.net/') ||
url.startsWith('https://rewards.bing.com/widget/') ||
url.startsWith('https://th.bing.com/th?id=') ||
url.startsWith('https://www.bing.com/th?id=')
) {
return false;
Expand Down
9 changes: 8 additions & 1 deletion autotests/tests/main/exists.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {test} from 'autotests';
import {getPageCookies} from 'autotests/context';
import {Main, Search} from 'autotests/pageObjects/pages';
import {Search as SearchRoute} from 'autotests/routes/pageRoutes';
import {getFullPackConfig} from 'autotests/utils';
import {expect} from 'e2ed';
import {expect, step} from 'e2ed';
import {
assertPage,
navigateToPage,
Expand Down Expand Up @@ -39,6 +40,8 @@ test('exists', {meta: {testId: '1'}, testIdleTimeout: 10_000, testTimeout: 15_00
'dynamic custom pack properties is correct',
).gt(0);

await step('Some step');

const urlObjectPromise = waitForStartOfPageLoad();

const mainPage = await navigateToPage(Main, {language});
Expand All @@ -57,6 +60,10 @@ test('exists', {meta: {testId: '1'}, testIdleTimeout: 10_000, testTimeout: 15_00

await expect(mainPage.searchQuery, 'search query on page is empty').eql('');

await step('Another step', () => {
getPageCookies();
});

await mainPage.typeIntoSearchInput(searchQuery);

await expect(mainPage.searchQuery, 'search query on page has setted value').eql(searchQuery);
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export {WebSocketRoute} from './WebSocketRoute';
export {createClientFunction} from './createClientFunction';
export {createTestFunction} from './createTestFunction';
export {expect} from './expect';
export {step} from './step';
30 changes: 30 additions & 0 deletions src/step.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {LogEventType} from './constants/internal';
import {setCustomInspectOnFunction} from './utils/fn';
import {log} from './utils/log';

import type {MaybePromise} from './types/internal';

import {test as playwrightTest} from '@playwright/test';

type Options = Readonly<{skipLogs?: boolean; timeout?: number}>;

const noop = (): void => {};

/**
* Declares a test step (calls Playwright's `test.step` function inside).
*/
export const step = (
name: string,
body: () => MaybePromise<void> = noop,
options?: Options,
): Promise<void> => {
if (options?.skipLogs !== true) {
if (body !== noop) {
setCustomInspectOnFunction(body);
}

log(name, {body: body === noop ? undefined : body, options}, LogEventType.InternalCore);
}

return playwrightTest.step(name, body, options);
};