greyhound
End-to-end browser testing framework
Last updated 6 years ago by johngeorgewright .
ISC · Original npm · Tarball · package.json
$ cnpm install greyhound 
SYNC missed versions from official npm registry.

Greyhound (alpha)

An end-to-end testing framework for node

Installation

The following instructions will only work after the first proper release

  1. Install the Selenium Chrome Driver
  2. Create a NPM module: mkdir my-e2e-testing && cd my-e2e-testing && npm init
  3. Install Greyhound: npm i --save greyhound
  4. Check that it works: greyhound -h

Getting Started

  1. Create the required directories mkdir -p test-scripts/pages
  2. Create a page object:
# test/scripts/pages/google/home.coffee
{Page} = require "greyhound"

class GoogleHome extends Page

  configure: ->
    @options.url = "http://www.google.com"

  searchBox: ->
    @findElement css: "input[name='q']"

  searchFor: (query) ->
    @searchBox().sendKeys "#{query}\n"

module.exports = GoogleHome

Or in Javascript:

// test/scripts/pages/google/home.js
var Page = require("greyhound").Page,
    util = require("util");

function GoogleHome() {
  this.constructor.super_.apply(this, arguments);
}

util.inherits(GoogleHome, Page);

util._extend(GoogleHome.prototype, {

  configure: function () {
    this.options.url = "http://www.google.com";
  },

  searchBox: function () {
    this.findElement({css: "input[name='q']"});
  },

  searchFor: function (query) {
    this.searchBox().sendKeys(query + "\n");
  }
  
});

module.exports = GoogleHome;

Or in LiveScript:

# test/scripts/pages/google/home.ls
{Page} = require \greyhound

class GoogleHome extends Page

  configure: ->
    @options.url = \http://www.google.com

  search-box: ->
    @find-element css: \input[name:'q']

  search-for: (query) ->
    @search-box!send-keys "#query\n"

module.exports = GoogleHome
  1. Create your first test script:
# test-scripts/google-search.coffee
{TestScript} = require "greyhound"
GoogleHome = require "./pages/google/home"

class GoogleSearch extends TestScript

  configure: ->
    @options.scriptName = "Google Search"

  execute: ->
    homePage = @page GoogleHome
    homePage.visit()
    homePage.searchFor "Greyhound"

module.exports = GoogleSearch

Or in JavaScript:

// test-scripts/google-search.js
var TestScript = require("greyhound").TestScript,
    GoogleHome = require("./pages/google/home"),
    util = require("util");

function GoogleSearch() {
  this.constructor.super_.apply(this, arguments);
}

util.inherits(GoogleSearch, TestScript);

util._extend(GoogleSearch.prototype, {

  configure: function () {
    this.options.scriptName = "Google Search";
  },

  execute: function () {
    var homePage = this.page(GoogleHome);
    homePage.visit();
    homePage.searchFor("Greyhound");
  }
  
});

module.exports = GoogleSearch;

Or in LiveScript:

# test-scripts/google-search.ls
require! {
  greyhound.TestScript
  \./pages/google/home
  util
}

class GoogleSearch

  configure: ->
    @options.script-name = 'Google Search'

  execute: ->
    home-page = @page GoogleHome
    home-page.visit!
    home-page.search-for \Greyhound

module.exports = GoogleSearch

4. Run your script `$ greyhound google-search`
5. View the report in a browser

Contributing
------------

### Setup

Here's my recommended set-up while developing on this project:

1. Make sure you have the required packages installed for [Growl](https://github.com/visionmedia/node-growl).
2. Fork/clone the project somewhere locally `git clone git@github.com:MyMedsAndMe/greyhound.js.git`
3. Install all dependencies and globally link it `sudo npm link`
4. Run the builder `npm run watch-compile`. As the project is built in CoffeeScript, this will continually compile the project to JavaScript, watching the files for any changes.
5. Open another terminal and run the tests `npm run watch-test`. This will run the tests everytime you change a test file.
6. If you want to try Greyhound in another project, while still developing on it, create your project and link your local version of Greyhound: `npm link greyhound` (make sure you have followed step 3 first).

### Coding standards

- All files to be named in lowercase and the words to be separated with hyphens.
- Variables, properties, methods and functions to be named in camelcase, first letter must be lowercase.
- Classes to be named in camelcase, first letter must be uppercase.
- Use CoffeeScript's style of string concatenation.
- Leave an empty line at the end of every file.
- Functions to have a gap between the properties and the arrow. Ie `(prop, prop2) ->`
- Functions without properties don't include the paranthesis `->`
- Be as clean as possible, make your code semantic and make your code readable without comments. Ie, use lots of nicely named functions instead.

Current Tags

  • 0.0.3                                ...           latest (6 years ago)

4 Versions

  • 0.0.3                                ...           6 years ago
  • 0.0.2                                ...           6 years ago
  • 0.0.1                                ...           6 years ago
  • 0.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (17)
Dev Dependencies (6)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |