Code Monkey home page Code Monkey logo

webdriverio-ts-mocha's Introduction

WebdriverIO TypeScript Mocha Framework

This is a sample project that uses WebdriverIO and TypeScript. It includes examples of the PageObject pattern and some practical examples for using WebdriverIO for cross browser and parallel run. testing inside container, report portal integration.

Requirements

NodeJs VSCode

Getting Started

Clone Repository

git clone https://github.com/sadabnepal/webdriverio-ts-mocha.git
cd webdriverio-ts-mocha

Install packages:

npm install

Run tests:

npm run test            [ test in chrome ]
npm run test:edge       [ test in edge ]
npm run cross:browser   [ test in chrome and edge ]

Docker Run:

npm run docker:start    [ start the docker container ]
npm run docker:stop     [ stop the docker container ]

npm run test:docker     [ test in docker container ]

npm run docker:start:arm    [ start the docker container for mac m1 chip ]
npm run docker:stop:arm     [ stop the docker container for mac m1 chip ]

open http://localhost:4444/ to check if server is running

Generate report with historical data:

npm run move
npm run report

Sample Report

allure_report

Generate offline html report:

npm run report:html

Cleanup Report folder

npm run cleanup

Github Action Workflow

docker_run

BrowserStack Integration

  • Follow Browser Stack Integration Getting Started document
  • Note down BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY from profile section
  • Paste value in .env for above copied content. Refer .env.example file
  • Run npm run test:bs command to execute test in browser stack

browser_stack

Report Portal Integration

  • Setup: follow https://reportportal.io/installation
  • Login: Open http://localhost:8080/ and login with time user superadmin and password erebus
  • Generate API key:
    • Click on bottom left of logged in user --> click on Profile
    • Click on API KEYS --> Generate API Key --> copy the generated key
    • Create .env file in root project folder. Refer .env.example file
    • Paste your API key into .env file as REPORT_PORTAL_KEY=<your api key>
  • Enter REPORT_PORTAL_PROJECT=<project_assignment> into .env. Value can be found on PROJECT ASSIGNMENT tab of user profile
  • Other details are updated in tests/config/wdio.reportPortal.ts file
  • add REPORT_PORTAL_SWITCH=ON to push results to report portal

docker_run

Key Features

  • Custom types for web elements
  • Parallel execution and Cross browser testing
  • Docker for testing against/using containerization
  • Github actions CI/CD integration
  • Report portal integration
  • BrowserStack Integration
  • dotenv to store secrets locally
  • eslint linting tools integrated
  • husky git hooks for pre-commit checks (eslint)

Folder Structure

├───.github
├───.husky
├───.vscode
├───images
├───tests
|    ├───config
|    ├───docker
|    ├───pages
|    ├───resources
|    ├───specs
|    ├───static
|    └───types
├───.env
├───.env.example
├───.eslintrc.js
├───.gitignore
├───docker-compose.yml
├───package-lock.json
├───package.json
├───README.md
└───tsconfig.json

webdriverio-ts-mocha's People

Contributors

sadabnepal avatar

Stargazers

Iniyavan avatar Posakhau avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.