diff --git a/Dockerfile b/Dockerfile index 6d843c15..32b55af3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -FROM node:20.10.0-alpine AS node +FROM node:20.3.1-alpine AS node -FROM alpine:3.18.5 +FROM alpine:3.19.0 COPY --from=node /usr/lib /usr/lib COPY --from=node /usr/local/lib /usr/local/lib @@ -9,7 +9,7 @@ COPY --from=node /usr/local/bin /usr/local/bin RUN apk --no-cache upgrade && \ apk --no-cache add \ - bash libevent npm chromium firefox xwininfo xvfb dbus eudev ttf-freefont fluxbox procps tzdata icu-data-full + bash libevent chromium firefox xwininfo xvfb dbus eudev ttf-freefont fluxbox procps tzdata icu-data-full COPY ./build/node_modules/e2ed /node_modules/e2ed diff --git a/autotests/configurator/logFieldReplacer.ts b/autotests/configurator/logFieldReplacer.ts index a72e66a8..6c4911f1 100644 --- a/autotests/configurator/logFieldReplacer.ts +++ b/autotests/configurator/logFieldReplacer.ts @@ -1,4 +1,4 @@ -import {getShallowCopyOfObjectForLogs, getStringTrimmedToMaxLength} from 'e2ed/utils'; +import {getShallowCopyOfObjectForLogs, getStringTrimmedToMaxLength} from 'e2ed/configurator'; import type {FieldReplacer} from 'e2ed/types'; diff --git a/autotests/configurator/mapBackendResponseErrorToLog.ts b/autotests/configurator/mapBackendResponseErrorToLog.ts index 854136b1..588c819e 100644 --- a/autotests/configurator/mapBackendResponseErrorToLog.ts +++ b/autotests/configurator/mapBackendResponseErrorToLog.ts @@ -1,5 +1,3 @@ -import {getDurationWithUnits} from 'e2ed/utils'; - import type {MapBackendResponseErrorToLog} from 'autotests/types/packSpecific'; /** @@ -12,7 +10,7 @@ import type {MapBackendResponseErrorToLog} from 'autotests/types/packSpecific'; * If the function returns `undefined`, the response is not logged (skipped). */ export const mapBackendResponseErrorToLog: MapBackendResponseErrorToLog = ({ - completionTimeInMs, + duration, request, responseBody, responseHeaders, @@ -22,17 +20,5 @@ export const mapBackendResponseErrorToLog: MapBackendResponseErrorToLog = ({ return undefined; } - const {requestBody, utcTimeInMs, ...requestWithoutBody} = request; - - const duration = getDurationWithUnits(completionTimeInMs - utcTimeInMs); - - return { - duration, - request: { - requestBody: requestBody instanceof Buffer ? String(requestBody) : requestBody, - ...requestWithoutBody, - }, - responseBody: responseBody instanceof Buffer ? String(responseBody) : responseBody, - responseHeaders, - }; + return {duration, request, responseBody, responseHeaders}; }; diff --git a/autotests/configurator/mapBackendResponseToLog.ts b/autotests/configurator/mapBackendResponseToLog.ts index 20ab6cd9..e61baa5c 100644 --- a/autotests/configurator/mapBackendResponseToLog.ts +++ b/autotests/configurator/mapBackendResponseToLog.ts @@ -1,5 +1,3 @@ -import {getDurationWithUnits} from 'e2ed/utils'; - import type {MapBackendResponseToLog} from 'autotests/types/packSpecific'; /** @@ -10,15 +8,13 @@ import type {MapBackendResponseToLog} from 'autotests/types/packSpecific'; * If the function returns `undefined`, the response is not logged (skipped). */ export const mapBackendResponseToLog: MapBackendResponseToLog = ({ - completionTimeInMs, - request, + duration, statusCode, + request, }) => { if (statusCode >= 400) { return undefined; } - const duration = getDurationWithUnits(completionTimeInMs - request.utcTimeInMs); - - return {duration, statusCode, url: request?.url}; + return {duration, statusCode, url: request.url}; }; diff --git a/package-lock.json b/package-lock.json index 5ea87763..a68320b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,9 +21,9 @@ "e2ed-init": "bin/init.js" }, "devDependencies": { - "@types/node": "20.10.3", - "@typescript-eslint/eslint-plugin": "6.13.2", - "@typescript-eslint/parser": "6.13.2", + "@types/node": "20.10.4", + "@typescript-eslint/eslint-plugin": "6.14.0", + "@typescript-eslint/parser": "6.14.0", "assert-modules-support-case-insensitive-fs": "1.0.1", "assert-package-lock-is-consistent": "1.0.0", "eslint": "8.55.0", @@ -32,7 +32,7 @@ "eslint-plugin-import": "2.29.0", "eslint-plugin-simple-import-sort": "10.0.0", "husky": "8.0.3", - "prettier": "3.1.0", + "prettier": "3.1.1", "testcafe": "3.4.0", "typescript": "5.3.3" }, @@ -2032,9 +2032,9 @@ } }, "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "13.23.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.23.0.tgz", - "integrity": "sha512-XAmF0RjlrjY23MA51q3HltdlGxUpXPvg0GioKiD9X6HD28iMjo2dKC8Vqwm7lne4GNr78+RHTfliktR6ZH09wA==", + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -2200,9 +2200,9 @@ "integrity": "sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==" }, "node_modules/@types/node": { - "version": "20.10.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.3.tgz", - "integrity": "sha512-XJavIpZqiXID5Yxnxv3RUDKTN5b81ddNC3ecsA0SoFXz/QU8OGBwZGMomiq0zw+uuqbL/krztv/DINAQ/EV4gg==", + "version": "20.10.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.4.tgz", + "integrity": "sha512-D08YG6rr8X90YB56tSIuBaddy/UXAA9RKJoFvrsnogAum/0pmjkgi4+2nx96A330FmioegBWmEYQ+syqCFaveg==", "dependencies": { "undici-types": "~5.26.4" } @@ -2214,16 +2214,16 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.13.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.13.2.tgz", - "integrity": "sha512-3+9OGAWHhk4O1LlcwLBONbdXsAhLjyCFogJY/cWy2lxdVJ2JrcTF2pTGMaLl2AE7U1l31n8Py4a8bx5DLf/0dQ==", + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.14.0.tgz", + "integrity": "sha512-1ZJBykBCXaSHG94vMMKmiHoL0MhNHKSVlcHVYZNw+BKxufhqQVTOawNpwwI1P5nIFZ/4jLVop0mcY6mJJDFNaw==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.13.2", - "@typescript-eslint/type-utils": "6.13.2", - "@typescript-eslint/utils": "6.13.2", - "@typescript-eslint/visitor-keys": "6.13.2", + "@typescript-eslint/scope-manager": "6.14.0", + "@typescript-eslint/type-utils": "6.14.0", + "@typescript-eslint/utils": "6.14.0", + "@typescript-eslint/visitor-keys": "6.14.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -2249,15 +2249,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "6.13.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.13.2.tgz", - "integrity": "sha512-MUkcC+7Wt/QOGeVlM8aGGJZy1XV5YKjTpq9jK6r6/iLsGXhBVaGP5N0UYvFsu9BFlSpwY9kMretzdBH01rkRXg==", + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.14.0.tgz", + "integrity": "sha512-QjToC14CKacd4Pa7JK4GeB/vHmWFJckec49FR4hmIRf97+KXole0T97xxu9IFiPxVQ1DBWrQ5wreLwAGwWAVQA==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "6.13.2", - "@typescript-eslint/types": "6.13.2", - "@typescript-eslint/typescript-estree": "6.13.2", - "@typescript-eslint/visitor-keys": "6.13.2", + "@typescript-eslint/scope-manager": "6.14.0", + "@typescript-eslint/types": "6.14.0", + "@typescript-eslint/typescript-estree": "6.14.0", + "@typescript-eslint/visitor-keys": "6.14.0", "debug": "^4.3.4" }, "engines": { @@ -2277,13 +2277,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "6.13.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.13.2.tgz", - "integrity": "sha512-CXQA0xo7z6x13FeDYCgBkjWzNqzBn8RXaE3QVQVIUm74fWJLkJkaHmHdKStrxQllGh6Q4eUGyNpMe0b1hMkXFA==", + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.14.0.tgz", + "integrity": "sha512-VT7CFWHbZipPncAZtuALr9y3EuzY1b1t1AEkIq2bTXUPKw+pHoXflGNG5L+Gv6nKul1cz1VH8fz16IThIU0tdg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.13.2", - "@typescript-eslint/visitor-keys": "6.13.2" + "@typescript-eslint/types": "6.14.0", + "@typescript-eslint/visitor-keys": "6.14.0" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -2294,13 +2294,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "6.13.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.13.2.tgz", - "integrity": "sha512-Qr6ssS1GFongzH2qfnWKkAQmMUyZSyOr0W54nZNU1MDfo+U4Mv3XveeLZzadc/yq8iYhQZHYT+eoXJqnACM1tw==", + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.14.0.tgz", + "integrity": "sha512-x6OC9Q7HfYKqjnuNu5a7kffIYs3No30isapRBJl1iCHLitD8O0lFbRcVGiOcuyN837fqXzPZ1NS10maQzZMKqw==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "6.13.2", - "@typescript-eslint/utils": "6.13.2", + "@typescript-eslint/typescript-estree": "6.14.0", + "@typescript-eslint/utils": "6.14.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -2321,9 +2321,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "6.13.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.13.2.tgz", - "integrity": "sha512-7sxbQ+EMRubQc3wTfTsycgYpSujyVbI1xw+3UMRUcrhSy+pN09y/lWzeKDbvhoqcRbHdc+APLs/PWYi/cisLPg==", + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.14.0.tgz", + "integrity": "sha512-uty9H2K4Xs8E47z3SnXEPRNDfsis8JO27amp2GNCnzGETEW3yTqEIVg5+AI7U276oGF/tw6ZA+UesxeQ104ceA==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -2334,13 +2334,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "6.13.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.13.2.tgz", - "integrity": "sha512-SuD8YLQv6WHnOEtKv8D6HZUzOub855cfPnPMKvdM/Bh1plv1f7Q/0iFUDLKKlxHcEstQnaUU4QZskgQq74t+3w==", + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.14.0.tgz", + "integrity": "sha512-yPkaLwK0yH2mZKFE/bXkPAkkFgOv15GJAUzgUVonAbv0Hr4PK/N2yaA/4XQbTZQdygiDkpt5DkxPELqHguNvyw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.13.2", - "@typescript-eslint/visitor-keys": "6.13.2", + "@typescript-eslint/types": "6.14.0", + "@typescript-eslint/visitor-keys": "6.14.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -2382,17 +2382,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "6.13.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.13.2.tgz", - "integrity": "sha512-b9Ptq4eAZUym4idijCRzl61oPCwwREcfDI8xGk751Vhzig5fFZR9CyzDz4Sp/nxSLBYxUPyh4QdIDqWykFhNmQ==", + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.14.0.tgz", + "integrity": "sha512-XwRTnbvRr7Ey9a1NT6jqdKX8y/atWG+8fAIu3z73HSP8h06i3r/ClMhmaF/RGWGW1tHJEwij1uEg2GbEmPYvYg==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.13.2", - "@typescript-eslint/types": "6.13.2", - "@typescript-eslint/typescript-estree": "6.13.2", + "@typescript-eslint/scope-manager": "6.14.0", + "@typescript-eslint/types": "6.14.0", + "@typescript-eslint/typescript-estree": "6.14.0", "semver": "^7.5.4" }, "engines": { @@ -2407,12 +2407,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "6.13.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.13.2.tgz", - "integrity": "sha512-OGznFs0eAQXJsp+xSd6k/O1UbFi/K/L7WjqeRoFE7vadjAF9y0uppXhYNQNEqygjou782maGClOoZwPqF0Drlw==", + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.14.0.tgz", + "integrity": "sha512-fB5cw6GRhJUz03MrROVuj5Zm/Q+XWlVdIsFj+Zb1Hvqouc8t+XP2H5y53QYU/MGtd2dPg6/vJJlhoX3xc2ehfw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.13.2", + "@typescript-eslint/types": "6.14.0", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -3820,9 +3820,9 @@ } }, "node_modules/eslint/node_modules/globals": { - "version": "13.23.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.23.0.tgz", - "integrity": "sha512-XAmF0RjlrjY23MA51q3HltdlGxUpXPvg0GioKiD9X6HD28iMjo2dKC8Vqwm7lne4GNr78+RHTfliktR6ZH09wA==", + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -5754,9 +5754,9 @@ } }, "node_modules/prettier": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.0.tgz", - "integrity": "sha512-TQLvXjq5IAibjh8EpBIkNKxO749UEWABoiIZehEPiY4GNpVdhaFKqSTu+QrlU6D2dPAfubRmtJTi4K4YkQ5eXw==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.1.tgz", + "integrity": "sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==", "dev": true, "bin": { "prettier": "bin/prettier.cjs" diff --git a/package.json b/package.json index 869e8dd3..58e1f56b 100644 --- a/package.json +++ b/package.json @@ -32,9 +32,9 @@ "testcafe-without-typecheck": "3.4.0-rc.1" }, "devDependencies": { - "@types/node": "20.10.3", - "@typescript-eslint/eslint-plugin": "6.13.2", - "@typescript-eslint/parser": "6.13.2", + "@types/node": "20.10.4", + "@typescript-eslint/eslint-plugin": "6.14.0", + "@typescript-eslint/parser": "6.14.0", "assert-modules-support-case-insensitive-fs": "1.0.1", "assert-package-lock-is-consistent": "1.0.0", "eslint": "8.55.0", @@ -43,7 +43,7 @@ "eslint-plugin-import": "2.29.0", "eslint-plugin-simple-import-sort": "10.0.0", "husky": "8.0.3", - "prettier": "3.1.0", + "prettier": "3.1.1", "testcafe": "3.4.0", "typescript": "5.3.3" }, diff --git a/src/configurator/getReplacedObject.ts b/src/configurator/getReplacedObject.ts index 27d070b8..2503aa55 100644 --- a/src/configurator/getReplacedObject.ts +++ b/src/configurator/getReplacedObject.ts @@ -19,9 +19,7 @@ export const getReplacedObject = ( return value; } - const replacedObject = ( - Array.isArray(value) ? [] : Object.create(Object.getPrototypeOf(value) as object | null) - ) as Value; + const replacedObject = (Array.isArray(value) ? [] : {}) as Value; const keys: PropertyKey[] = Object.keys(value); diff --git a/src/configurator/index.ts b/src/configurator/index.ts index e3f0fda5..3507ef54 100644 --- a/src/configurator/index.ts +++ b/src/configurator/index.ts @@ -1,4 +1,6 @@ export type {UserlandPack as PackConfig} from '../types/internal'; +export {getDurationWithUnits} from '../utils/getDurationWithUnits'; +export {getShallowCopyOfObjectForLogs, getStringTrimmedToMaxLength} from '../utils/valueToString'; export {RunEnvironment, startTimeInMs} from './constants'; export {replaceFields} from './replaceFields'; export {runEnvironment} from './runEnvironment'; diff --git a/src/types/http/http.ts b/src/types/http/http.ts index 70693371..dde1e740 100644 --- a/src/types/http/http.ts +++ b/src/types/http/http.ts @@ -90,6 +90,7 @@ export type Response< SomeRequest extends Request = Request, > = Readonly<{ completionTimeInMs?: UtcTimeInMs; + duration?: string; request?: SomeRequest; responseBody: ResponseBody; responseHeaders: ResponseHeaders; diff --git a/src/utils/expect/createExpectMethod.ts b/src/utils/expect/createExpectMethod.ts index c86e958b..8196412b 100644 --- a/src/utils/expect/createExpectMethod.ts +++ b/src/utils/expect/createExpectMethod.ts @@ -33,7 +33,7 @@ export const createExpectMethod = ( function method(...args: Parameters) { assertionTimeout ??= getFullPackConfig().assertionTimeout; - const timeout = assertionTimeout ?? 0; + const timeout = assertionTimeout + 1_000; const message = getAssertionMessage(...args); const {clearRejectTimeout, promiseWithTimeout, reject, setRejectTimeoutFunction} = @@ -42,7 +42,7 @@ export const createExpectMethod = ( setRejectTimeoutFunction(() => { const timeoutWithUnits = getDurationWithUnits(timeout); const error = new E2edError( - `${key}-assertion promise rejected after ${timeoutWithUnits} timeout`, + `"${key}" assertion promise rejected after ${timeoutWithUnits} timeout`, ); reject(error); diff --git a/src/utils/index.ts b/src/utils/index.ts index 5d9316d7..644fc932 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -29,7 +29,6 @@ export {E2edError, getStackTrace} from './error'; export {getFunctionPresentationForLogs, setCustomInspectOnFunction} from './fn'; export {writeFile} from './fs'; export {removeStyleFromString} from './generalLog'; -export {getDurationWithUnits} from './getDurationWithUnits'; export {getFullPackConfig as untypedGetFullPackConfig} from './getFullPackConfig'; export {getKeysCounter} from './getKeysCounter'; export {log} from './log'; @@ -43,9 +42,5 @@ export {setReadonlyProperty} from './setReadonlyProperty'; export {getPackageInfo} from './startInfo'; export {wrapInTestRunTracker} from './testRun'; export {isArray, isReExecutablePromise, isThenable} from './typeGuards'; -export { - getShallowCopyOfObjectForLogs, - getStringTrimmedToMaxLength, - valueToString, -} from './valueToString'; +export {valueToString} from './valueToString'; export {isSelectorEntirelyInViewport, isSelectorInViewport} from './viewport'; diff --git a/src/utils/requestHooks/RequestHookToWaitForEvents.ts b/src/utils/requestHooks/RequestHookToWaitForEvents.ts index 4e16ce1a..e9af9797 100644 --- a/src/utils/requestHooks/RequestHookToWaitForEvents.ts +++ b/src/utils/requestHooks/RequestHookToWaitForEvents.ts @@ -6,6 +6,7 @@ import { } from '../../constants/internal'; import {assertValueIsDefined} from '../asserts'; +import {getDurationWithUnits} from '../getDurationWithUnits'; import {mapBackendResponseForLogs} from '../log'; import {setReadonlyProperty} from '../setReadonlyProperty'; import {addNotCompleteRequest, completeRequest, processEventsPredicates} from '../waitForEvents'; @@ -88,6 +89,10 @@ export class RequestHookToWaitForEvents extends RequestHookWithEvents { const response = await getResponseFromResponseEvent(event); + const duration = getDurationWithUnits(response.completionTimeInMs - request.utcTimeInMs); + + setReadonlyProperty(response, 'duration', duration); + setReadonlyProperty(response, 'request', request); const responseWithRequest = response as ResponseWithRequest;