Skip to content

Commit 39625c4

Browse files
authored
Merge pull request #120 from joomcode/feat/selector-find-accept-selectors
feat: add global warnings for TestUnhandledRejection instead of errors
2 parents 4980a0c + cd9c834 commit 39625c4

37 files changed

Lines changed: 1055 additions & 463 deletions

autotests/tests/switchingPagesForResponses.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ test(
6363

6464
await expect(
6565
numberOfSentRequests === numberOfCaughtResponses ||
66+
numberOfSentRequests === numberOfCaughtResponses + 2 ||
6667
numberOfSentRequests === numberOfCaughtResponses + 1 ||
6768
numberOfSentRequests === numberOfCaughtResponses - 1,
6869
`almost all responses were caught (${numberOfCaughtResponses} of ${numberOfSentRequests})`,

package-lock.json

Lines changed: 838 additions & 366 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,26 @@
2525
"url": "git+https://github.com/joomcode/e2ed.git"
2626
},
2727
"dependencies": {
28-
"@playwright/test": "1.52.0",
28+
"@playwright/test": "1.53.2",
2929
"create-locator": "0.0.27",
3030
"get-modules-graph": "0.0.11",
3131
"sort-json-keys": "1.0.3"
3232
},
3333
"devDependencies": {
34-
"@playwright/browser-chromium": "1.52.0",
35-
"@types/node": "22.15.21",
34+
"@playwright/browser-chromium": "1.53.2",
35+
"@types/node": "24.0.8",
3636
"@typescript-eslint/eslint-plugin": "7.18.0",
3737
"@typescript-eslint/parser": "7.18.0",
3838
"assert-modules-support-case-insensitive-fs": "1.0.1",
3939
"assert-package-lock-is-consistent": "1.0.0",
4040
"eslint": "8.57.1",
4141
"eslint-config-airbnb-base": "15.0.0",
4242
"eslint-config-prettier": "10.1.5",
43-
"eslint-plugin-import": "2.31.0",
43+
"eslint-plugin-import": "2.32.0",
4444
"eslint-plugin-simple-import-sort": "12.1.1",
4545
"eslint-plugin-typescript-sort-keys": "3.3.0",
4646
"husky": "9.1.7",
47-
"prettier": "3.5.3",
47+
"prettier": "3.6.2",
4848
"typescript": "5.8.3"
4949
},
5050
"peerDependencies": {

src/ApiRoute.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@ export abstract class ApiRoute<
1313
/**
1414
* Request type of API route.
1515
*/
16-
// eslint-disable-next-line @typescript-eslint/naming-convention
17-
declare readonly __REQUEST_KEY: SomeRequest;
16+
declare readonly Request: SomeRequest;
1817

1918
/**
2019
* Response type of API route.
2120
*/
22-
// eslint-disable-next-line @typescript-eslint/naming-convention
23-
declare readonly __RESPONSE_KEY: SomeResponse;
21+
declare readonly Response: SomeResponse;
2422

2523
/**
2624
* Returns `true`, if the request body is in JSON format.

src/WebSocketRoute.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ export abstract class WebSocketRoute<
1616
/**
1717
* Request type of WebSocket route.
1818
*/
19-
// eslint-disable-next-line @typescript-eslint/naming-convention
20-
declare readonly __REQUEST_KEY: SomeRequest;
19+
declare readonly Request: SomeRequest;
2120

2221
/**
2322
* Response type of WebSocket route.
2423
*/
25-
// eslint-disable-next-line @typescript-eslint/naming-convention
26-
declare readonly __RESPONSE_KEY: SomeResponse;
24+
declare readonly Response: SomeResponse;
2725

2826
/**
2927
* Returns `true`, if the request body is in JSON format.

src/actions/setHeadersAndNavigateToUrl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ export const setHeadersAndNavigateToUrl = async (
2929
return route.fallback();
3030
}
3131

32-
const {navigationTimeout} = getFullPackConfig();
32+
const timeout = navigateToUrlOptions?.timeout ?? getFullPackConfig().navigationTimeout;
3333

34-
const response = await route.fetch({timeout: navigationTimeout});
34+
const response = await route.fetch({timeout});
3535
const headers = response.headers();
3636

3737
applyHeadersMapper(headers, mapResponseHeaders);

src/constants/internal.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export {
5353
EVENTS_DIRECTORY_PATH,
5454
EXPECTED_SCREENSHOTS_DIRECTORY_PATH,
5555
GLOBAL_ERRORS_PATH,
56+
GLOBAL_WARNINGS_PATH,
5657
INSTALLED_E2ED_DIRECTORY_PATH,
5758
INTERNAL_DIRECTORY_NAME,
5859
INTERNAL_REPORTS_DIRECTORY_PATH,
@@ -63,7 +64,7 @@ export {
6364
TMP_DIRECTORY_PATH,
6465
} from './paths';
6566
/** @internal */
66-
export {TEST_ENDED_ERROR_MESSAGE} from './playwright';
67+
export {TARGET_CLOSED_ERROR_MESSAGE, TEST_ENDED_ERROR_MESSAGE} from './playwright';
6768
/** @internal */
6869
export {RESOLVED_PROMISE} from './promise';
6970
/** @internal */

src/constants/paths.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@ export const EXPECTED_SCREENSHOTS_DIRECTORY_PATH = join(
128128
*/
129129
export const GLOBAL_ERRORS_PATH = join(TMP_DIRECTORY_PATH, 'globalErrors.txt') as FilePathFromRoot;
130130

131+
/**
132+
* Relative (from root) path to file with global warnings of run.
133+
* @internal
134+
*/
135+
export const GLOBAL_WARNINGS_PATH = join(
136+
TMP_DIRECTORY_PATH,
137+
'globalWarnings.txt',
138+
) as FilePathFromRoot;
139+
131140
/**
132141
* Relative (from root) path to directory with tests screenshots.
133142
* @internal

src/constants/playwright.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Playwright error message for already closed target (`TargetClosedError`).
3+
* @internal
4+
*/
5+
export const TARGET_CLOSED_ERROR_MESSAGE = 'Target page, context or browser has been closed';
6+
17
/**
28
* Playwright error message for already ended test.
39
* @internal

src/createClientFunction.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {TEST_ENDED_ERROR_MESSAGE} from './constants/internal';
1+
import {TARGET_CLOSED_ERROR_MESSAGE, TEST_ENDED_ERROR_MESSAGE} from './constants/internal';
22
import {getTestIdleTimeout} from './context/testIdleTimeout';
33
import {E2edError} from './utils/error';
44
import {setCustomInspectOnFunction} from './utils/fn';
@@ -13,7 +13,6 @@ import type {ClientFunction} from './types/internal';
1313
type Options = Readonly<{name?: string; retries?: number; timeout?: number}>;
1414

1515
const contextErrorMessage = 'Execution context was destroyed';
16-
const targetErrorMessage = 'Target page, context or browser has been closed';
1716

1817
/**
1918
* Creates a client function.
@@ -48,7 +47,7 @@ export const createClientFunction = <Args extends readonly unknown[], Result>(
4847

4948
if (
5049
errorString.includes(contextErrorMessage) ||
51-
errorString.includes(targetErrorMessage) ||
50+
errorString.includes(TARGET_CLOSED_ERROR_MESSAGE) ||
5251
errorString.includes(TEST_ENDED_ERROR_MESSAGE)
5352
) {
5453
await page.waitForLoadState();
@@ -58,7 +57,7 @@ export const createClientFunction = <Args extends readonly unknown[], Result>(
5857

5958
if (
6059
suberrorString.includes(contextErrorMessage) ||
61-
suberrorString.includes(targetErrorMessage) ||
60+
suberrorString.includes(TARGET_CLOSED_ERROR_MESSAGE) ||
6261
suberrorString.includes(TEST_ENDED_ERROR_MESSAGE)
6362
) {
6463
return new Promise(() => {});
@@ -80,7 +79,7 @@ export const createClientFunction = <Args extends readonly unknown[], Result>(
8079

8180
if (
8281
suberrorString.includes(contextErrorMessage) ||
83-
suberrorString.includes(targetErrorMessage) ||
82+
suberrorString.includes(TARGET_CLOSED_ERROR_MESSAGE) ||
8483
suberrorString.includes(TEST_ENDED_ERROR_MESSAGE)
8584
) {
8685
return new Promise(() => {});

0 commit comments

Comments
 (0)