Skip to content

Commit

Permalink
Issue 227 E2E Test: ReadMe File (#230)
Browse files Browse the repository at this point in the history
ReadMe for E2E Test which contains:
- Prerequisites
- Installation and setup
- Test Execution and Report
  • Loading branch information
vishalkharge authored Jan 9, 2023
1 parent 0d197fc commit 1ad9bee
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 3 deletions.
119 changes: 119 additions & 0 deletions apps/e2e-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# E2E-Test Framework

The test automation framework for end-to-end testing with Cucumber-JS and Playwright. It abstracts browser interaction to simple steps that are written from a user perspective.

## Prerequisites

In order to run the automated test, you will need the following tools installed on your machine.

- NodeJS v16.16.0
- Yarn v1.22.19

## Project structure

This project is setup as a yarn based nx-managed monorepo, and e2e tests are located under apps/e2e-test/\* and contains the following:

- features: contains the bdd feature files which has scenarios
- selector-mappings: contains the element locators stored in yaml or json file with component and page model
- src: contains the config, hooks, logger, utils, step definitions, reporter and playwright tool specific actions
- scripts: contains the bash script to install publisher and viewer app locally
- reports: contains the test execution artifacts and HTML report
- test.config.ts: contains the test config

## Installation and setup

To install the necessary libraries, clone the repo. Then from the root directory of the project, run the following command in a terminal window:

```bash
yarn
```

## [Optional] Publisher and Viewer app installation locally

Follow the Millicast Tokens section of the main ReadMe [ReadMe file](../../README.md) to configure the token as environment variable

To launch the Publisher and Viewer App locally, run the following command:

```bash
yarn nx launch-server e2e-test
```

Once the script is executed, open the .test.env file to get the Publisher and Viewer URL

```bash
cat .test.env
VIEWER_URL=http://localhost:4173/
PUBLISHER_URL=http://localhost:4174/
```

## Setup Browser and Headless Mode for test execution:

Tests are executed on chrome browser and in headless mode by default.

To set the different browser, insert/update the following variable in the bash environment:

```bash
export BROWSER_NAME=<chrome/firefox/chromium>
```

To set the HEADLESS mode, insert/update the following variable in the bash environment:

```bash
export HEADLESS=<true/false>
```

## Setup Publisher and Viewer app URL for test execution:

If the Publisher and Viewer app is launched locally using the 'yarn nx launch-server e2e-test' command then skip setting the PUBLISHER_URL and VIEWER_URL environment variables.
To set the Publisher and Viewer URL, insert/update the following variable in the bash environment:

```bash
export PUBLISHER_URL='http://localhost:4174/'
export VIEWER_URL='http://localhost:4173/'
```

To set if the Viewer URL has dynamic stream name, insert/update the following variable in the bash

```bash
export DYNAMIC_STREAM_NAME=<true/false>
```

## Test Execution and Report

### Run All Tests/Features

```bash
yarn nx test e2e-test --skip-nx-cache
```

### Run Specific Tests/Features/Scenarios

To run the all the scenarios from a specific feature file, tag the feature with `@only` as shown below:

![only-feature screenshot](../../docs/img/only-feature.png)

To run the specific scenario(s) from a feature file, tag the scenario(s) with `@only` as shown below:

![only-scenario screenshot](../../docs/img/only-scenario.png)

```bash
yarn nx only e2e-test --skip-nx-cache
```

### Ignore Tests

To ignore the test execution of specific scenario(s) or feature file, tag it with `@ignore` as shown below:

![ignore-scenario-feature screenshot](../../docs/img/ignore-scenario.png)

```bash
yarn nx test e2e-test --skip-nx-cache
```

### Generate HTML Reports

```bash
yarn nx test-report e2e-test --skip-nx-cache
```

HTML test report will be available under apps/e2e-test/reports/\* directory.
6 changes: 3 additions & 3 deletions apps/e2e-test/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"executor": "nx:run-commands",
"options": {
"commands": [
"if [ {args.report} != undefined ]; then mkdir -p {args.report}; export REPORT_PATH={args.report}; fi; cucumber-js --config ./apps/e2e-test/cucumber.ts"
"if [ {args.report} != undefined ]; then mkdir -p {args.report}; export REPORT_PATH={args.report}; fi; cucumber-js --config ./apps/e2e-test/cucumber.ts --tags \"not @ignore\""
]
},
"dependsOn": [{ "projects": "self", "target": "cleanup", "params": "forward" }]
Expand All @@ -47,7 +47,7 @@
"executor": "nx:run-commands",
"options": {
"commands": [
"if [ {args.report} != undefined ]; then mkdir -p {args.report}; export REPORT_PATH={args.report}; fi; cucumber-js --config ./apps/e2e-test/cucumber.ts --tags \"@publisher and not @local\""
"if [ {args.report} != undefined ]; then mkdir -p {args.report}; export REPORT_PATH={args.report}; fi; cucumber-js --config ./apps/e2e-test/cucumber.ts --tags \"@publisher and not @local and not @ignore\""
]
},
"dependsOn": [{ "projects": "self", "target": "cleanup", "params": "forward" }]
Expand All @@ -56,7 +56,7 @@
"executor": "nx:run-commands",
"options": {
"commands": [
"if [ {args.report} != undefined ]; then mkdir -p {args.report}; export REPORT_PATH={args.report}; fi; cucumber-js --config ./apps/e2e-test/cucumber.ts --tags \"@viewer and not @local\""
"if [ {args.report} != undefined ]; then mkdir -p {args.report}; export REPORT_PATH={args.report}; fi; cucumber-js --config ./apps/e2e-test/cucumber.ts --tags \"@viewer and not @local and not @ignore\""
]
},
"dependsOn": [{ "projects": "self", "target": "cleanup", "params": "forward" }]
Expand Down
Binary file added docs/img/ignore-scenario.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/only-feature.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/only-scenario.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1ad9bee

Please sign in to comment.