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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: npm
node-version: 20.16.0
node-version: 22.14.0
- run: npm ci
- run: npm run build
- run: npm run build:docker
Expand All @@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: npm
node-version: 20.16.0
node-version: 22.14.0
- run: npm ci
- run: npm run build
- run: npm run lint
Expand All @@ -34,7 +34,7 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: npm
node-version: 20.16.0
node-version: 22.14.0
- run: npm ci
- run: npm run build
- run: npm run test:local
Expand Down
52 changes: 26 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@
"url": "git+https://github.com/joomcode/e2ed.git"
},
"dependencies": {
"@playwright/test": "1.50.1",
"@playwright/test": "1.51.0",
"create-locator": "0.0.27",
"get-modules-graph": "0.0.11",
"globby": "11.1.0"
},
"devDependencies": {
"@playwright/browser-chromium": "1.50.1",
"@types/node": "22.13.9",
"@playwright/browser-chromium": "1.51.0",
"@types/node": "22.13.10",
"@typescript-eslint/eslint-plugin": "7.18.0",
"@typescript-eslint/parser": "7.18.0",
"assert-modules-support-case-insensitive-fs": "1.0.1",
"assert-package-lock-is-consistent": "1.0.0",
"eslint": "8.57.1",
"eslint-config-airbnb-base": "15.0.0",
"eslint-config-prettier": "10.0.1",
"eslint-config-prettier": "10.1.1",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-simple-import-sort": "12.1.1",
"eslint-plugin-typescript-sort-keys": "3.3.0",
Expand Down
33 changes: 17 additions & 16 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ Modules in the dependency graph should only import the modules above them:
7. `configurator`
8. `utils/getHash`
9. `generators`
10. `utils/viewport`
11. `utils/parse`
12. `utils/distanceBetweenSelectors`
13. `utils/getDurationWithUnits`
14. `utils/setReadonlyProperty`
15. `utils/paths`
16. `utils/valueToString`
17. `utils/error`
18. `utils/asserts`
10. `utils/headers`
11. `utils/viewport`
12. `utils/parse`
13. `utils/distanceBetweenSelectors`
14. `utils/getDurationWithUnits`
15. `utils/valueToString`
16. `utils/error`
17. `utils/asserts`
18. `utils/object`
19. `utils/uiMode`
20. `utils/runLabel`
21. `utils/clone`
Expand All @@ -44,10 +44,11 @@ Modules in the dependency graph should only import the modules above them:
37. `utils/pack`
38. `useContext`
39. `context`
40. `utils/selectors`
41. `selectors`
42. `utils/log`
43. `utils/waitForEvents`
44. `utils/expect`
45. `expect`
46. ...
40. `utils/apiStatistics`
41. `utils/selectors`
42. `selectors`
43. `utils/log`
44. `utils/waitForEvents`
45. `utils/expect`
46. `expect`
47. ...
2 changes: 1 addition & 1 deletion src/actions/mock/mockApiRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {assertValueIsDefined} from '../../utils/asserts';
import {setCustomInspectOnFunction} from '../../utils/fn';
import {log} from '../../utils/log';
import {getRequestsFilter, getSetResponse} from '../../utils/mockApiRoute';
import {setReadonlyProperty} from '../../utils/setReadonlyProperty';
import {setReadonlyProperty} from '../../utils/object';

import type {
ApiMockFunction,
Expand Down
2 changes: 1 addition & 1 deletion src/actions/mock/mockWebSocketRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {assertValueIsDefined} from '../../utils/asserts';
import {setCustomInspectOnFunction} from '../../utils/fn';
import {log} from '../../utils/log';
import {getRequestsFilter, getSetResponse} from '../../utils/mockWebSocketRoute';
import {setReadonlyProperty} from '../../utils/setReadonlyProperty';
import {setReadonlyProperty} from '../../utils/object';

import type {
WebSocketMockFunction,
Expand Down
24 changes: 15 additions & 9 deletions src/actions/pages/navigateToPage.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import {LogEventType} from '../../constants/internal';
import {addPageToApiStatistics} from '../../utils/apiStatistics';
import {getDocumentUrl} from '../../utils/document';
import {getDurationWithUnits} from '../../utils/getDurationWithUnits';
import {log} from '../../utils/log';

import {createPageInstance} from './createPageInstance';

import type {AnyPageClassType, NavigateToOrAssertPageArgs, UtcTimeInMs} from '../../types/internal';
import type {
AnyPageClassType,
NavigateToOrAssertPageArgs,
PageName,
UtcTimeInMs,
} from '../../types/internal';

/**
* Navigates to the page by page class and page params.
Expand All @@ -24,9 +30,10 @@ export const navigateToPage = async <SomePageClass extends AnyPageClassType>(
const url = route.getUrl();
const startNavigateTimeInMs = Date.now() as UtcTimeInMs;
const pageInstanceCreatedInMs = startNavigateTimeInMs - startTimeInMs;
const pageName = PageClass.name as PageName;

log(
`Will navigate to the page "${PageClass.name}"`,
`Will navigate to the page "${pageName}"`,
{pageInstanceCreatedInMs, pageParams, routeParams, url},
LogEventType.InternalAction,
);
Expand All @@ -36,7 +43,7 @@ export const navigateToPage = async <SomePageClass extends AnyPageClassType>(
await page.navigateToPage(url);

log(
`Navigation to the page "${PageClass.name}" completed`,
`Navigation to the page "${pageName}" completed`,
{pageParams, routeParams, url},
LogEventType.InternalAction,
);
Expand All @@ -52,13 +59,12 @@ export const navigateToPage = async <SomePageClass extends AnyPageClassType>(

await page.afterNavigateToPage?.();

const durationWithUnits = getDurationWithUnits(Date.now() - startNavigateTimeInMs);
const duration = Date.now() - startNavigateTimeInMs;
const durationWithUnits = getDurationWithUnits(duration);

log(
`Page "${PageClass.name}" loaded in ${durationWithUnits}`,
{url},
LogEventType.InternalAction,
);
log(`Page "${pageName}" loaded in ${durationWithUnits}`, {url}, LogEventType.InternalAction);

addPageToApiStatistics({duration, pageName, url});

return page;
};
2 changes: 1 addition & 1 deletion src/actions/setHeadersAndNavigateToUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {AsyncLocalStorage} from 'node:async_hooks';

import {LogEventType} from '../constants/internal';
import {getPlaywrightPage} from '../useContext';
import {applyHeadersMapper} from '../utils/headers';
import {log} from '../utils/log';
import {applyHeadersMapper} from '../utils/requestHooks';

import {navigateToUrl} from './navigateToUrl';

Expand Down
2 changes: 1 addition & 1 deletion src/actions/waitFor/waitForAllRequestsComplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {E2edError} from '../../utils/error';
import {setCustomInspectOnFunction} from '../../utils/fn';
import {getDurationWithUnits} from '../../utils/getDurationWithUnits';
import {log} from '../../utils/log';
import {setReadonlyProperty} from '../../utils/object';
import {getPromiseWithResolveAndReject} from '../../utils/promise';
import {setReadonlyProperty} from '../../utils/setReadonlyProperty';
import {
getInitialIdsForAllRequestsCompletePredicate,
getUrlsByRequestHookContextIds,
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {assertValueIsTrue} from './utils/asserts';
import {assertUserlandPack} from './utils/config/assertUserlandPack';
import {getPathToPack} from './utils/environment';
import {setCustomInspectOnFunction} from './utils/fn';
import {setReadonlyProperty} from './utils/setReadonlyProperty';
import {setReadonlyProperty} from './utils/object';
import {isUiMode} from './utils/uiMode';
import {isLocalRun} from './configurator';

Expand Down
1 change: 1 addition & 0 deletions src/constants/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export {CREATE_PAGE_TOKEN} from './pages';
export {
ABSOLUTE_PATH_TO_INSTALLED_E2ED_DIRECTORY,
ABSOLUTE_PATH_TO_PROJECT_ROOT_DIRECTORY,
API_STATISTICS_PATH,
AUTOTESTS_DIRECTORY_PATH,
COMPILED_USERLAND_CONFIG_DIRECTORY,
CONFIG_PATH,
Expand Down
11 changes: 10 additions & 1 deletion src/constants/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,20 @@ export const TESTS_DIRECTORY_PATH = join(
) as DirectoryPathFromRoot;

/**
* Relative (from root) path to tmp directory.
* Relative (from root) path to temporary directory.
* @internal
*/
export const TMP_DIRECTORY_PATH = join(REPORTS_DIRECTORY_PATH, 'tmp') as DirectoryPathFromRoot;

/**
* Relative (from root) path to file with total API statistics of run.
* @internal
*/
export const API_STATISTICS_PATH = join(
TMP_DIRECTORY_PATH,
'apiStatistics.txt',
) as FilePathFromRoot;

/**
* Relative (from root) path to directory with compiled pack configuration files.
* @internal
Expand Down
30 changes: 30 additions & 0 deletions src/context/apiStatistics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {useContext} from '../useContext';

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

/**
* Raw get and set internal (maybe `undefined`) API statistics.
* @internal
*/
const [getRawApiStatistics, setRawApiStatistics] = useContext<ApiStatistics>();

/**
* Get internal always defined API statistics.
* @internal
*/
export const getApiStatistics = (): ApiStatistics => {
const maybeApiStatistics = getRawApiStatistics();

if (maybeApiStatistics !== undefined) {
return maybeApiStatistics;
}

const apiStatistics: ApiStatistics = {
pages: Object.create(null) as {},
requests: Object.create(null) as {},
};

setRawApiStatistics(apiStatistics);

return apiStatistics;
};
Loading