Greyhound (alpha)
An end-to-end testing framework for node
Installation
The following instructions will only work after the first proper release
- Install the Selenium Chrome Driver
- Create a NPM module:
mkdir my-e2e-testing && cd my-e2e-testing && npm init
- Install Greyhound:
npm i --save greyhound
- Check that it works:
greyhound -h
Getting Started
- Create the required directories
mkdir -p test-scripts/pages
- Create a page object:
# test/scripts/pages/google/home.coffee require "greyhound" : -> @optionsurl = "http://www.google.com" : -> @findElement css: "input[name='q']" : @searchBoxsendKeys "\n" module.exports = GoogleHome
Or in Javascript:
// test/scripts/pages/google/home.jsvar Page = Page util = ; { thisconstructorsuper_;} util; util; moduleexports = 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
- Create your first test script:
# test-scripts/google-search.coffee require "greyhound"GoogleHome = require "./pages/google/home" : -> @optionsscriptName = "Google Search" : -> homePage = @page GoogleHome homePagevisit homePagesearchFor "Greyhound" module.exports = GoogleSearch
Or in JavaScript:
// test-scripts/google-search.jsvar TestScript = TestScript GoogleHome = util = ; { thisconstructorsuper_;} util; util; moduleexports = GoogleSearch;
Or in LiveScript:
# test-scripts/google-search.lsrequire! { 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.