Giter Site home page Giter Site logo

webcumbernode's Introduction

WebCumberNode Boilerplate

Cucumber JS with WebDriverJS in Node.JS

This is a little demo project, to run NodeJS, using Cucumber.js as a behaviour testing suite, for automated browser tests.

It gives you a base foundation to set up running BDD tests in any environment that has Node.JS and Selenium2-Server-Standalone WebDriver.

Ingredients

  • 1 part Node.JS, with a sprinkling of NPM
  • 1 part fresh Virtual Machine, running the Selenium2-Server-Standalone pakcage.
  • If you don't have the selenium server, get it here (.jar download)
  • You don't need a Virtual Machine to run selenium, although it makes the whole thing taste better
  • The VM should have one/many/all of Firefox, Chrome, Opera, IE, Safari

Instructions

First you need to pre-heat the VM, by turning it on and loading selenium server. Make sure you have the host-name set in ./features/support/testproperties.json to the IP address of your VM (or just 127.0.0.1 if you're running locally).

Also prepare your environment by running npm install. If you're feeling brave you can also install the dependencies globally, which helps with Cucumber as it installs a bin in your $PATH.

Now run ./node-modules/cucumber/bin/cucumber.js, or, if you installed globally, just cucumber.js will do.

Watch as your selenium server spins up a fresh copy of firefox, visits Google.com and runs a search, then shuts down and repeats for a second test.

If you want to change browser, just change the testproperties or run cucumber.js --browser='internet explorer', for example or cucumber.js --browser=safari.

If you want to test in chrome, you'll also need the ChromeDriver package. Consult the Selenium wiki for more.

File structure

Here is a categorisation of the main files you'll want to look at/edit:

  • features/*.feature - the story files you want to run.
  • support/teardown.js - closes the browser after each scenario
  • support/testproperties.json - Configuration stuffs
  • support/world.js - This is the bootstrapper for WebDriverJS, be careful!
  • step_definitions/generic.js - Good place to keep testwide step definitions, such as "I click "
  • step_definitions/*.js - Other step definitions, ideally you should have a 1-1 relationship between feature file and specific definitions as the complimentary .js file

webcumbernode's People

Contributors

keithamus avatar

Watchers

James Cloos avatar  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.