Full blown javascript + WebDriverIO e2e testing framework
- JavaScript 99.6%
- Shell 0.4%
|
|
||
|---|---|---|
| .husky | ||
| docs | ||
| projects/templateProject | ||
| reporters/json-testrail-reporter | ||
| support | ||
| .commitlintrc.json | ||
| .editorconfig | ||
| .env.example | ||
| .eslintrc | ||
| .gitignore | ||
| .lintstagedrc.json | ||
| .prettierignore | ||
| babel.config.js | ||
| docker-compose.yml | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
| wdio.conf.js | ||
Framework & E2E tests
- JS naming conventions link
Projects covered with E2E tests(used in configuration):
- template
System requirements
- Install Java: link. If you get this error ('error @wdio/selenium-standalone-service error selenium exited before it could start with code 1')
- Node v12+ (will be installed automatically via Volta.sh)
- Docker for allure reports(optional)
Installation
npm install
Usage
npm run test -- --platform=DESKTOP_CHROME --project=template --testEnv=stagingAll tests within template project in Chrome(by default) browser.npm run test -- --platform=DESKTOP_CHROME --project=template --site= --testEnv=staging --suite loginRun specific tests, which are grouped to suites.npm run test -- --platform=DESKTOP_CHROME --project=template --testEnv=staging --spec ./projects/template/test/specs/template.spec.jsRun one specific test file.docker-compose up -dIt will spin up docker containers for local Allure reports, reports will be automatically generated every 40seconds(configured indocker-compose.yml)
Reporting
- Spec(CLI) - default, useful for local testing
- Allure (by default works only in CI, tests are being sent to the centralized allure reporter
via a client imported as a npm package. For local setup, before running tests
- Execute in CLI
docker-compose up -d. - Browse to
localhost:5252and login (In the docker-compose.yml is the user and password) - Create your project in the server
- Modify your
wdio.conf.jsin the onComplete hook the allure host, user and password to the correct ones - Run some tests with
ENV=CI. - Tests should be uploaded to your local allure
- Execute in CLI
- TestRail - custom implementation, reporting works in CI environment. Visit https://template.testrail.io
- You can find the implementation on the
wdio.conf.jsfile and the custom reporter in./reporter/json-testrail-reporter - if for some reason you are testing it
locallythen don't forget to remove previous test-run results before new test run. TestRail results folder:projects/<project_name>/out
- You can find the implementation on the
Add new project
In order to start new project and use existing shared helpers you need to:
- Create new folder under
projectsfolder - e.gprojects/template - Copy-paste
wdio.shared.conf.jsand browser specific config file(s) (wdio.DESKTOP_CHROME.conf.js) fromprojects/template/configtoprojects/template/config - Add new folder(s) structure where u will have your tests (specs and PageObject files if needed) e.g
projects/template/test/specs - Modify
wdio.shared.conf.jsaccording to your needs:baseUrlstring of th or some mappingspecs- depending on the structure from point #3suites- optional and can be removed completelyframework- test framework (jasmine/mocha/cucumber)reporters- refer to #Reporting section and choose which ones you need.onPrepare- modify according to your needs. Allure environment variables are defined hereonComplete- modify according to your needs. Allure and Testrail reporters logic is used there, so it might be not needed in your case.
- Add test file(s) in
specsfolder and you are ready to run tests locally. Refer to #Usage section.
How to execute tests in CI
To execute tests on circleci you will need to first push your tests into a branch, then you have 2 options
Via circle-ci (For full regression)
- Access circleci pipeline https://app.circleci.com/pipelines/
- Select your branch
- Click on trigger pipeline button
- Add following obligatory parameters:
| Parameter type | Name | Value |
|---|---|---|
| String | project | your project folder name (template ) |
| String | environment | your environment (t2, staging, prelive, live) |
- Optional parameters
| Parameter type | Name | Value |
|---|---|---|
| String | specFilter | Specify specs to run |
| String | suitesFilter | Specify suites to run |
| boolean | testrailReport | Enables testrail report |
| int | testrailProjectId | Id of the testrail project (Mandatory if testrailReport enabled) |
| int | testrailPlanId | Id of the testrail test plan (Mandatory if testrailReport enabled) |
| boolean | xrayReport | Enables xray report |
| int | xrayTestPlan | Id of the xray test plan (Mandatory if XrayReport enabled) |
| int | xrayTestExecution | Id of the xray test execution |
| String | site | IF you have sites to run inside the project (template => sitetemplate) |
- Click again on trigger pipeline button in popup
- Wait until job its finished
Webdriver.IO FAQ
Project structure:
docs- folder with other documentation related to this projectsupport- folder for shared util/helper files, available globally. You can import it from any subdirectory like this:import ElementUtil from 'support/element-util';support/browserCommands- helper file with globally available methods within browser scopesupport/elementCommands- helper file with globally available methods within element scopeprojects- different websites/brands that has e2e testsreporters- contains custom reporters(e.g TestRail)projects/<project_name>/test/specs- main folder where e2e tests/assertions are writtenprojects/<project_name>/test/pages- main folder where all abstraction for UI element interaction is written.projects/<project_name>/config- main folder where all project configuration related files residesprojects/<project_name>/api- main folder where API functions for querying BackEnd Services/BackOfficeprojects/<project_name>/fixtures- main folder where test data residesprojects/<project_name>/constants- main folder with constants that are reused across the projectenv.example- list of some ENVironment variables that can are used mostly in CI env. Not mandatory in local env.