Giter VIP home page Giter VIP logo

codeceptjs-nightmare-harness's Introduction

CodeceptJS Nightmare Test Harness

The following repository provides a basic structure for testers to quickly spin up their own automation projects using CodeceptJS and Nightmare.

Setup Info

First, to install the necessary packages run npm install. This will install the following packages:

  • CodeceptJS
  • CodeceptJS-Nightmare
  • Nightmare
  • Nightmare-upload
  • Mochawesome

Tip: If you run into SyntaxError: Unexpected token ), you can follow the suggestions on this issue to clear things up.

This repo has already initialized a codeceptjs-nightmare project. However, if you want to initialize a new project, simply delete codecept.json, run codeceptjs init, and follow the prompts.

Additional Test Setup

CodeceptJS provides generators for different parts of your tests. We have already provided a few samples you can use as templates. To generate any new files, you can run the following:

  • Test Scenarios: codeceptjs gt
  • Page Objects: codeceptjs gpo
  • Page Fragments (modals or widgets, for example): codeceptjs go --type fragment
  • Step Objects: codeceptjs go --type step

Each generator will update the includes section of codecept.json.

Running Tests

Once everything is installed, you can simply execute npm tests to run the existing test. The codecept.json file houses the configurations needed to run tests. Here is a portion of that file with notes on important features:

{
  "output": "./output", // screenshots for failures
  "helpers": {
    "Nightmare": {
      "url": "https://moduscreate.com/",
      "show": true, // tests run in a window
      "restart": false // uses a single browser instance
    }
  },
  "include": { // set up by codeceptjs generators
    "modusHomePage": "./pages/modusHomePage.js",
    "modusEmailModalFragment": "./fragments/modusEmailModal.js",
    "navigateHomePageStep": "./steps/navigateHomePageStep.js"
  }
}

Tags

CodeceptJS offers the ability to group scenarios using tags. This gives you greater flexibility in how you organize tests.

Scenario('Navigate to Home Page @home', () => {});

To run based on tags, execute codeceptjs run --grep @tagName. CodeceptJS also provides more advanced regex filtering.

  • --grep (?=.*@smoke2)(?=.*@smoke3) - run tests with @smoke2 and @smoke3 in name
  • --grep @smoke2|@smoke3 - run tests with @smoke2 or @smoke3 in name
  • --grep ((?=.*@smoke2)(?=.*@smoke3))|@smoke4 - run tests with (@smoke2 and @smoke3) or @smoke4 in name
  • --grep (?=.*@smoke2)^(?!.*@smoke3) - run tests with @smoke2 but without @smoke3 in name

Reporters

CodeceptJS offers a few different reporter options. This repo is set up with mochawesome, a tool for generating HTML reports.

Docker-Compose

This project comes with the ability to run tests in a Docker container via docker-compose. It uses the Docker image from the Codeception team, and provides all of the necessary dependencies to run tests.

Run docker-compose up -d codeceptjs then docker-compose run --rm codeceptjs.

codeceptjs-nightmare-harness's People

Contributors

mallorym avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

isabella232

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.