diff --git a/README.md b/README.md index b8efb9c3..ef1d31a6 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,8 @@ After the run, a detailed HTML report and a summary lite report in JSON format a ## Adding e2ed to a project -Prerequisites: [node](https://nodejs.org/en/) >=16, -[TypeScript](https://www.typescriptlang.org/) >=4.8. +Prerequisites: [node](https://nodejs.org/en/) >=20, +[TypeScript](https://www.typescriptlang.org/) >=5. All commands below are run from the root directory of the project. diff --git a/autotests/packs/allTests.ts b/autotests/packs/allTests.ts index 9380d586..99aca4fa 100644 --- a/autotests/packs/allTests.ts +++ b/autotests/packs/allTests.ts @@ -31,7 +31,7 @@ const browserFlags = [ const filterTestsIntoPack: FilterTestsIntoPack = ({options}) => options.meta.testId !== '13'; const userAgent = - 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.35 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.35'; + 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36'; const msInMinute = 60_000; const packTimeoutInMinutes = 5; diff --git a/autotests/pageObjects/pages/E2edReportExample/E2edReportExample.ts b/autotests/pageObjects/pages/E2edReportExample/E2edReportExample.ts index 2b8dc584..7e38c7ba 100644 --- a/autotests/pageObjects/pages/E2edReportExample/E2edReportExample.ts +++ b/autotests/pageObjects/pages/E2edReportExample/E2edReportExample.ts @@ -109,4 +109,8 @@ export class E2edReportExample extends Page { return setPageCookiesAndNavigateToUrl(url, this.pageCookies); } + + override async waitForPageLoaded(): Promise { + await this.waitForDomContentLoaded(); + } } diff --git a/bin/dockerEntrypoint.sh b/bin/dockerEntrypoint.sh index a009c3db..083a480a 100755 --- a/bin/dockerEntrypoint.sh +++ b/bin/dockerEntrypoint.sh @@ -2,14 +2,6 @@ set -eo pipefail set +u -restoreE2edPackage() { - if [[ -d "./node_modules/_e2ed" ]] - then - echo "Restore temporarily hiding locally installed e2ed package:" - mv --verbose ./node_modules/_e2ed ./node_modules/e2ed - fi -} - onExit() { if [[ $PID ]] && ps -p $PID > /dev/null then @@ -20,20 +12,12 @@ onExit() { sleep "${E2ED_TIMEOUT_FOR_GRACEFUL_SHUTDOWN_IN_SECONDS:-16}" fi - restoreE2edPackage; - echo "Exit from docker entrypoint" exit } trap "onExit" EXIT -#if [[ -d "./node_modules/e2ed" ]] -#then -# echo "Temporarily hide locally installed e2ed package:" -# mv --verbose ./node_modules/e2ed ./node_modules/_e2ed -#fi - if [[ -z $E2ED_DEBUG ]] then /node_modules/e2ed/bin/runE2edInDockerEnvironment.js & PID=$! diff --git a/bin/localEntrypoint.sh b/bin/localEntrypoint.sh new file mode 100755 index 00000000..c57b0956 --- /dev/null +++ b/bin/localEntrypoint.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -eo pipefail +set +u + +BIN_DIR="$(dirname "$(realpath "$BASH_SOURCE")")" + +if [[ -z $E2ED_DEBUG ]] +then + "$BIN_DIR/runE2edInLocalEnvironment.js" "$@" +else + node --inspect-brk "$BIN_DIR/runE2edInLocalEnvironment.js" "$@" +fi diff --git a/package.json b/package.json index 245c804a..76f12f92 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "author": "uid11", "license": "MIT", "bin": { - "e2ed": "./bin/runE2edInLocalEnvironment.js", + "e2ed": "./bin/localEntrypoint.sh", "e2ed-init": "./bin/init.js", "e2ed-install-browsers": "./bin/installBrowsers.sh" }, @@ -92,7 +92,7 @@ "build:remove:types-js": "find ./build/node_modules/e2ed/types/ -name *.js -exec rm {} \\;", "postbuild:remove": "touch ./build/node_modules/e2ed/types/index.js", "build:copy": "npm run build:copy:bin && npm run build:copy:scripts && npm run build:copy:meta && npm run build:copy:example && npm run build:copy:tsconfig", - "build:copy:bin": "cp ./bin/dockerEntrypoint.sh ./bin/installBrowsers.sh ./build/node_modules/e2ed/bin", + "build:copy:bin": "cp ./bin/dockerEntrypoint.sh ./bin/installBrowsers.sh ./bin/localEntrypoint.sh ./build/node_modules/e2ed/bin", "postbuild:copy:bin": "npm run make:executable build/node_modules/e2ed/bin/init.js build/node_modules/e2ed/bin/runE2edInLocalEnvironment.js build/node_modules/e2ed/bin/runE2edInDockerEnvironment.js", "build:copy:scripts": "cp ./build/scripts/*.js ./build", "build:copy:meta": "cp -R ./LICENSE ./logo.svg ./README.md ./styles ./build/node_modules/e2ed", @@ -118,7 +118,7 @@ "test:docker:copy": "cp -R ./build/autotests ./build/docker/autotests && cp ./build/tsconfig.json ./build/docker", "posttest:docker:copy": "rm -rf ./build/docker/autotests/reports && ./bin/addPackageJsonToBuildDocker.sh", "test:docker": "(cd ./build/docker && E2ED_ORIGIN=https://google.com ./autotests/bin/runDocker.sh ./autotests/packs/allTests.ts)", - "test:local": "(cd ./build && E2ED_ORIGIN=https://google.com ./node_modules/e2ed/bin/runE2edInLocalEnvironment.js ./autotests/packs/allTests.ts)" + "test:local": "(cd ./build && E2ED_ORIGIN=https://google.com ./node_modules/e2ed/bin/localEntrypoint.sh ./autotests/packs/allTests.ts)" }, "sideEffects": false, "types": "index.d.ts" diff --git a/src/utils/events/registerEndTestRunEvent.ts b/src/utils/events/registerEndTestRunEvent.ts index 6624067c..a68f27cf 100644 --- a/src/utils/events/registerEndTestRunEvent.ts +++ b/src/utils/events/registerEndTestRunEvent.ts @@ -1,3 +1,4 @@ +import {isLocalRun} from '../../configurator'; import {isDebug, TestRunStatus} from '../../constants/internal'; import {getFullMocksState} from '../../context/fullMocks'; import {getPlaywrightPage} from '../../useContext'; @@ -99,7 +100,7 @@ export const registerEndTestRunEvent = async (endTestRunEvent: EndTestRunEvent): await writeTestRunToJsonFile(fullTestRun); await writeLogsToFile(); - if (isDebug) { + if (isDebug && isLocalRun) { await getPlaywrightPage().pause(); } }; diff --git a/src/utils/tests/runTests.ts b/src/utils/tests/runTests.ts index 4a3f8988..9d390150 100644 --- a/src/utils/tests/runTests.ts +++ b/src/utils/tests/runTests.ts @@ -1,5 +1,6 @@ import {fork} from 'node:child_process'; +import {isLocalRun} from '../../configurator'; import {CONFIG_PATH, e2edEnvironment, isDebug} from '../../constants/internal'; import {getFullPackConfig} from '../config'; @@ -43,8 +44,7 @@ export const runTests = async ({runLabel}: RunRetryOptions): Promise => { await new Promise((resolve, reject) => { const playwrightArgs = ['test', `--config=${CONFIG_PATH}`]; - if (isDebug) { - // playwrightArgs.unshift('--node-options=--inspect-brk'); + if (isDebug && isLocalRun) { e2edEnvironment.PWDEBUG = 'console'; playwrightArgs.push('--debug'); } @@ -59,7 +59,10 @@ export const runTests = async ({runLabel}: RunRetryOptions): Promise => { beforeRunFirstTest(); } - const playwrightProcess = fork(playwrightCliPath, playwrightArgs, {stdio: 'pipe'}); + const playwrightProcess = fork(playwrightCliPath, playwrightArgs, { + execArgv: [], + stdio: 'pipe', + }); playwrightProcess.stdout?.on('data', (data) => { const stringData = stripExtraLogs(String(data).trim()).trim();