Giter VIP home page Giter VIP logo

wdio-mocha's Introduction

Webdriver IO Template

1. Prerequisites

1.1. Node.js:

Install the latest Node.js Recommended For Most Users from https://nodejs.org/en/

1.2. Install Git:

https://git-scm.com/

1.3. Install Java SE Development Kit:

https://www.oracle.com/java/technologies/javase-jdk14-downloads.html

Additional MacOS prerequisites:

1.4. Install Xcode:

https://developer.apple.com/xcode/

1.5. Use Git Bash instead of using Windows Command Prompt (for WebStorm).

  1. Open WebStorm
  2. Go to File => Settings
  3. Go to Tools => Terminal
  4. Specify Shell Path to Git Bash e.g.C:\Program Files\Git\bin\sh.exe

To run tests:

  • Clone repository
  • Run npm install
  • Run npm test

WebDriverIO v6 project setup from scratch:

  1. Create new NodeJS project (or run npm init inside existing directory)
  2. Run npm i --save-dev @wdio/cli
  3. Run npx wdio config -y
  4. Run mkdir -p ./test/specs & mkdir -p ./test/pages & mkdir -p ./test/data
  5. Babel setup:
  • create babel.config.js and copy/paste following code:
 module.exports = {
    presets: [
        ['@babel/preset-env', {
            targets: {
                node: 12
            }
        }]
    ]
}
  • Run npm install --save-dev @babel/core @babel/cli @babel/preset-env @babel/register
  • In wdio.conf.js add babel to compilers:
mochaOpts: {
  ui: 'bdd',
  compilers: ['js:@babel/register'],
  timeout: 60000
},
  1. Prettier setup:
  • Run npm install --save-dev prettier
  • Create prettier.config.js and copy/paste following code:
module.exports = {
  trailingComma: 'all',
  tabWidth: 2,
  semi: true,
  singleQuote: true,
  bracketSpacing: true,
  arrowParens: 'avoid',
  parser: 'babel',
  printWidth: 100,
};
  1. Add Chai Assertions to your project:
  • Run npm install --save-dev chai
  • Setup chai in beforeTest function (so you won't have to import it everytime). Replace beforeTest function in wdio.conf js with following:
  beforeTest: function () {
    const chai = require('chai');
    global.expect = chai.expect;
  },
  1. To run your tests add npx wdio wdio.conf.js in package.json

Add Allure Reporter to existing WDIO framework:

  1. Install Allure Reporter npm install @wdio/allure-reporter --save-dev
  2. Add Allure to reporters in wdio.conf.js file:
  reporters: ['spec', ['allure', {
    outputDir: 'allure-results',
    disableWebdriverStepsReporting: false,
    disableWebdriverScreenshotsReporting: true,
  }]],
  1. Install CLI for Allure npm install allure-commandline --save-dev
  2. Add report script to your package.json file
    "report": "allure generate allure-results --clean && allure open",
  1. To take screenshot in wdio.conf.js add:
    afterTest: function(test, context, { error, result, duration, passed, retries }) {
        if (!passed) {
            browser.takeScreenshot();
        }
    }
  

wdio-mocha's People

Contributors

borodastov 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.