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
14 changes: 7 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
build-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
cache: npm
node-version: 24.14.0
Expand All @@ -20,8 +20,8 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
cache: npm
node-version: 24.14.0
Expand All @@ -32,15 +32,15 @@ jobs:
test-local:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
cache: npm
node-version: 24.14.0
- run: npm ci --force
- run: npm run build
- run: npm run test:local
- uses: actions/upload-artifact@v5
- uses: actions/upload-artifact@v7
if: ${{ always() }}
with:
name: reports
Expand Down
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ which in this case will be included in the start info object, and will be used f
Each function can thus access the results of the previous function.

`enableCsp: boolean`: enables Content-Security-Policy checks in browser.
This parameter can be overridden in the test-specific options.

`enableHeadlessMode: boolean`: enables headless mode (if browser supports such mode).

Expand Down Expand Up @@ -366,9 +367,11 @@ You can define the `SkipTests` type and `skipTests` processing rules in the hook

`takeFullPageScreenshotOnError: boolean`: if `true`, then takes a screenshot of the full page
(not just the viewport) at the time of the test error, for display in the HTML report.
This parameter can be overridden in the test-specific options.

`takeViewportScreenshotOnError: boolean`: if `true`, then takes a screenshot of the page viewport
at the time of the test error, for display in the HTML report.
This parameter can be overridden in the test-specific options.

`testFileGlobs: readonly string[]`: an array of globs with pack test (task) files.
`fs.glob` from `nodejs` is used for matching globs.
Expand All @@ -383,10 +386,13 @@ If the test run takes longer than this timeout, the test fails and rerun on the
This parameter can be overridden in the test-specific options.

`userAgent: string`: `userAgent` string of browser (device) in tests.
This parameter can be overridden in the test-specific options.

`viewportHeight: number`: height of viewport of page in pixels.
This parameter can be overridden in the test-specific options.

`viewportWidth: number`: width of viewport of page in pixels.
This parameter can be overridden in the test-specific options.

`waitBeforeRetry: (options: Options) => number`: returns how many milliseconds `e2ed`
should wait before running test (for retries).
Expand All @@ -412,17 +418,25 @@ If the wait is longer than this timeout, then the promise returned by the `waitF
`waitForResponseTimeout: number`: default timeout (in milliseconds) for `waitForResponse`/`waitForResponseToRoute` functions.
If the wait is longer than this timeout, then the promise returned by the `waitForResponse`/`waitForResponseToRoute` function will be rejected.

### Environment variables
### Project settings

General static project settings are stored in file `./autotests/projectSettings.json`. They apply to all project packs.

Required environment variables are defined in the `./autotests/variables.env` file (they cannot be deleted):
`allTestFileGlobs: string`: an array of globs covering all project test files across all packs
(used to generate a code report).

`E2ED_DOCKER_IMAGE`: the name of the docker image where the tests will run.
`dockerImage: string | null`: the name of the docker image where the tests will run.
The image must be based on the `e2ed` base image.

`E2ED_PATH_TO_TS_CONFIG_OF_PROJECT_FROM_ROOT`: the path to TypeScript config file of the project
`pathToTsConfigFromRoot: string`: the path to TypeScript config file of the project
from the root directory of the project. The project should have one common TypeScript config
for both the application code and the autotest code.

`testIdentifierKey: Record<string, string>`: an object with a single field that serves as the test identifier key in the test `meta`.
If the project does not use such a key, leave the object empty.

### Environment variables

You can pass the following optional environment variables to the `e2ed` process in any standard way:

`E2ED_ORIGIN`: origin-part of the url (`protocol` + `host`) on which the tests will be run. For example, `https://bing.com`.
Expand Down
5 changes: 2 additions & 3 deletions autotests/bin/runDocker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ set +u
CONTAINER_LABEL="e2ed"
DEBUG_PORT=$([[ $E2ED_DEBUG == inspect-brk:* ]] && echo "${E2ED_DEBUG#inspect-brk:}" || echo "")
DIR="${E2ED_WORKDIR:-$PWD}"
E2ED_DOCKER_IMAGE=$(grep -m1 \"dockerImage\": $DIR/autotests/projectSettings.json | cut -d '"' -f 4)
E2ED_TIMEOUT_FOR_GRACEFUL_SHUTDOWN_IN_SECONDS=16
MOUNTDIR="${E2ED_MOUNTDIR:-$DIR}"
WITH_DEBUG=$([[ -z $DEBUG_PORT ]] && echo "" || echo "--publish $DEBUG_PORT:$DEBUG_PORT --publish $((DEBUG_PORT + 1)):$((DEBUG_PORT + 1))")
VERSION=$(grep -m1 \"e2ed\": $DIR/package.json | cut -d '"' -f 4)

source ./autotests/variables.env

if [[ -z $E2ED_DOCKER_IMAGE ]]
then
echo "Error: The \"autotests/variables.env\" file does not contain E2ED_DOCKER_IMAGE variable."
echo "Error: The \"autotests/projectSettings.json\" file does not contain dockerImage variable."
echo "Add it so that \"runDocker.sh\" script can run the docker image."
echo "Exit with code 9"
exit 9
Expand Down
1 change: 1 addition & 0 deletions autotests/configurator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export {mapLogPayloadInReport} from './mapLogPayloadInReport';
export {matchScreenshot} from './matchScreenshot';
export {regroupSteps} from './regroupSteps';
export {skipTests} from './skipTests';
export {testIdentifierKey} from './testIdentifierKey';
export type {
DoAfterPack,
DoBeforePack,
Expand Down
3 changes: 2 additions & 1 deletion autotests/configurator/regroupSteps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {LogEventStatus, LogEventType} from 'e2ed/constants';
import {LOG_EVENT_STEP_TYPES, LogEventStatus, LogEventType} from 'e2ed/constants';
import {setReadonlyProperty} from 'e2ed/utils';

import type {LogEvent, Mutable} from 'e2ed/types';
Expand All @@ -8,6 +8,7 @@ import type {LogEvent, Mutable} from 'e2ed/types';
*/
export const regroupSteps = (logEvents: readonly LogEvent[]): readonly LogEvent[] => {
const topLevelTypes: readonly LogEventType[] = [
...LOG_EVENT_STEP_TYPES,
LogEventType.Action,
LogEventType.Assert,
LogEventType.Entity,
Expand Down
11 changes: 11 additions & 0 deletions autotests/configurator/testIdentifierKey.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {getTestIdentifierKey} from 'e2ed/configurator';

import projectSettings from '../projectSettings.json';

import type {GetTestIdentifierKey} from 'e2ed/types';

/**
* Project test identifier key in test meta.
*/
export const testIdentifierKey: GetTestIdentifierKey<typeof projectSettings> =
getTestIdentifierKey(projectSettings);
4 changes: 3 additions & 1 deletion autotests/configurator/types/testMeta.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type {testIdentifierKey} from 'autotests/configurator';

/**
* Test metadata parameters (testId, severity, etc).
*/
export type TestMeta = Readonly<{
testId: string;
[testIdentifierKey]: string;
}>;
2 changes: 1 addition & 1 deletion autotests/entities/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const getUsers = ({delay = 0, retries = 0}: GetUsersOptions = {}): Promis
fetch(`https://dummyjson.com/users?delay=${clientDelay}`, {method: 'GET'}).then(
(res) => res.json() as unknown,
),
{name: 'getUsers', retries, timeout: 6_000},
{name: 'getUsers', retries, timeout: 30_000},
);
}

Expand Down
4 changes: 2 additions & 2 deletions autotests/packs/allTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const browserFlags = [
const filterTestsIntoPack: FilterTestsIntoPack = ({options}) => options.meta.testId !== '13';

const userAgent =
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36';
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36';

const msInMinute = 60_000;
const packTimeoutInMinutes = 5;
Expand Down Expand Up @@ -82,7 +82,7 @@ export const pack: Pack = {
skipTests,
takeFullPageScreenshotOnError: false,
takeViewportScreenshotOnError: true,
testFileGlobs: ['**/autotests/tests/**/*.ts'],
testFileGlobs: ['autotests/tests/**/*.ts'],
testIdleTimeout: 8_000,
testTimeout: 15_000,
userAgent,
Expand Down
7 changes: 7 additions & 0 deletions autotests/projectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"allFeatureFileGlobs": ["autotests/specs/**/*.feature"],
"allTestFileGlobs": ["autotests/tests/**/*.ts"],
"dockerImage": "e2edhub/e2ed",
"pathToTsConfigFromRoot": "./tsconfig.json",
"testIdentifierKey": {"testId": "key of the test identifier in test meta"}
}
29 changes: 29 additions & 0 deletions autotests/specs/codeReport.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Feature: Code report

Scenario: Scenario without test identifier
Given base state
When action
Then result

@testId-901
Scenario: Scenario with test identifier and without test
Given base state
When action
Then result
And more
But not that
* anything

@testId-902 @testId-903
Scenario: Scenario with two test identifier tags
Given base state

@testId-904
Scenario: Scenario without steps

@testId-905
Scenario: Scenario with empty step
Given

@testId-36
Scenario: Scenario without steps linked to test
Loading