Skip to content
This repository has been archived by the owner on Feb 8, 2021. It is now read-only.

Commit

Permalink
Added common Meteor tasks to Storm
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesMGreene committed Mar 11, 2014
1 parent bb4bc6c commit f232e2a
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -7,3 +7,4 @@ chromedriver.log
libpeerconnection.log
changes.sh
xmloutput*
.DS_Store
1 change: 1 addition & 0 deletions .npmignore
Expand Up @@ -9,3 +9,4 @@ libpeerconnection.log
changes.sh
xmloutput*
.travis.yml
.DS_Store
46 changes: 22 additions & 24 deletions README.md
@@ -1,58 +1,56 @@
Meteor Storm [![Build Status](https://travis-ci.org/JamesMGreene/meteor-storm.png?branch=master)](https://travis-ci.org/JamesMGreene/meteor-storm)
MeteorStorm [![Build Status](https://travis-ci.org/JamesMGreene/meteor-storm.png?branch=master)](https://travis-ci.org/JamesMGreene/meteor-storm)
============

Meteor Storm is an end to end test framework for [Meteor](http://www.meteor.com/) applications built on top of [WebDriverJS](https://code.google.com/p/selenium/wiki/WebDriverJs). Meteor Storm runs tests against your application running in a real browser, interacting with it as a user would.
MeteorStorm is an end to end test framework for [Meteor](http://www.meteor.com/) applications built on top of [Protractor](https://github.com/angular/protractor) and [WebDriverJS](https://code.google.com/p/selenium/wiki/WebDriverJs). MeteorStorm runs tests against your application running in a real browser, interacting with it as a user would.

Meteor Storm can be run as a standalone binary, or included into your tests as a library. Use [Meteor Storm as a library](https://github.com/JamesMGreene/meteor-storm/blob/master/docs/library-only.md) if you would like to manage WebDriver and your test setup yourself.

For more information, [read the docs](https://github.com/JamesMGreene/meteor-storm/tree/master/docs/getting-started.md), or head over to the [FAQ](https://github.com/JamesMGreene/meteor-storm/blob/master/docs/faq.md).
MeteorStorm can be run as a standalone binary, or included into your tests as a library. Use MeteorStorm as a library if you would like to manage WebDriver and your test setup yourself.


To run the sample tests
-----------------------

Install Meteor Storm with:
Install MeteorStorm with:

npm install -g meteor-storm

Start up a selenium server (See the appendix below for help with this). By default, the tests expect the selenium server to be running at `http://localhost:4444/wd/hub`.

The node module's example folder contains a simple test suite which runs against angularjs.org. Run with:
The node module's `example` folder contains a simple test suite which runs against [meteor.com](http://www.meteor.com/). Run with:

storm example/conf.js


Using the Meteor Storm runner
Using the MeteorStorm Runner
-----------------------------

The Meteor Storm runner is a binary which accepts a config file. Install storm with
The MeteorStorm runner is a binary which accepts a config file. Install `storm` with:

npm install -g meteor-storm
# Run the line below to see command line options
storm

You will need a *configuration file* containing setup info and *test files* containing the actual test scripts. The config file specifies how the runner should start webdriver, where your test files are, and global setup options. The test files use Jasmine framework by default ([read about using mocha instead](https://github.com/JamesMGreene/meteor-storm/tree/master/docs/using-mocha.md)).
You will need a _configuration file_ containing setup info and *test files* containing the actual test scripts. The config file specifies how the runner should start webdriver, where your test files are, and global setup options. The test files use Jasmine framework by default but can also use Mocha or Cucumber.

Create a configuration file - an example with detailed comments is shown in `node_modules/meteor-storm/referenceConf.js`. Edit the configuration file to point to your test files.

```javascript
```js
// myConf.js
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['myTest.js', 'myTestFolder/*Test.js']
}
```

The configuration file must specify a way to connection to webdriver. This can be
* `seleniumAddress`: The address of a running selenium standalone server.
* `seleniumServerJar`: The location of the selenium standalone .jar file on your machine. Meteor Storm will use this to start up the selenium server.
* `sauceUser` and `sauceKey`: The username and key for a [SauceLabs](http://www.saucelabs.com) account. Meteor Storm will use this to run tests on SauceLabs.
The configuration file must specify a way to connection to WebDriver. This can be
* `seleniumAddress`: The address of a running Selenium standalone server.
* `seleniumServerJar`: The location of the Selenium standalone .jar file on your machine. MeteorStorm will use this to start up the selenium server.
* `sauceUser` and `sauceKey`: The username and key for a [SauceLabs](http://www.saucelabs.com) account. MeteorStorm will use this to run tests on SauceLabs.

The runner exposes global variables `browser`, `by` and `element`. Check out [getting started docs](https://github.com/JamesMGreene/meteor-storm/blob/master/docs/getting-started.md) to learn how to write a test.
The runner exposes global variables `browser`, `by` and `element`. Check out the `specs` folder to learn how to write a test.

```js
// myTest.js
describe('meteor homepage', function() {
describe('Meteor homepage', function() {
it('should greet the named user', function() {
browser.get('http://www.meteor.com/');

Expand All @@ -65,12 +63,12 @@ describe('meteor homepage', function() {
});
```

Run with
Run with:

storm myConf.js


Cloning and running Meteor Storm's own tests
Cloning and running MeteorStorm's own tests
--------------------------------------------
Clone the github repository.

Expand All @@ -80,30 +78,30 @@ Clone the github repository.

Start up a selenium server. By default, the tests expect the selenium server to be running at `http://localhost:4444/wd/hub`.

Meteor Storm's test suite runs against the included testapp. Start that up with
MeteorStorm's test suite runs against the included testapp. Start that up with:

cd testapp
./scripts/web-server.js

Then run the tests with
Then run the tests with:

npm test


Appendix A: Setting up a standalone selenium server
Appendix A: Setting up a standalone Selenium server
---------------------------------------------------

WebdriverJS does not natively include the selenium server - you must start a standalone selenium server. All you need is the latest [selenium-server-standalone.](https://code.google.com/p/selenium/downloads/list). To drive individual browsers, you may need to install separate driver binaries.

To use with chrome browsers, [download chromedriver](http://chromedriver.storage.googleapis.com/index.html).
[More information about chromedriver](https://sites.google.com/a/chromium.org/chromedriver/)

The `webdriver-manager` script is included in the npm package to manage downloads for you. To see the options, run
The `webdriver-manager` script is included in the npm package to manage downloads for you. To see the options, run:

npm install -g storm
webdriver-manager

Download and start the selenium server with
Download and start the selenium server with:

webdriver-manager update
webdriver-manager start
Expand Down
8 changes: 8 additions & 0 deletions lib/storm.js
Expand Up @@ -5,6 +5,7 @@ var webdriver = require('selenium-webdriver');

var clientSideScripts = require('./clientsidescripts.js');
var MeteorStormBy = require('./locators.js').MeteorStormBy;
var MeteorTasks = require('./tasks');

var WEB_ELEMENT_FUNCTIONS = [
'click', 'sendKeys', 'getTagName', 'getCssValue', 'getAttribute', 'getText',
Expand Down Expand Up @@ -532,6 +533,12 @@ var MeteorStorm = function(webdriver, opt_baseUrl, opt_rootElement) {
this.params = {};
};

for (var task in MeteorTasks) {
if (typeof task === "function") {
MeteorStorm.prototype[taskName] = MeteorTasks[taskName];
}
}

/**
* Instruct webdriver to wait until Meteor has finished rendering and has
* no outstanding $http calls before continuing.
Expand Down Expand Up @@ -968,3 +975,4 @@ exports.filterStackTrace = function(text) {
});
return lines.join('\n');
};

45 changes: 45 additions & 0 deletions lib/tasks.js
@@ -0,0 +1,45 @@
module.exports = {

/**
* @return Promise
*/
loginWithPassword: function(user, password) {
var driver = this && this.driver || browser && browser.driver;
return driver.executeScriptAsync(function() {
var callback = arguments[arguments.length - 1];
Meteor.loginWithPassword(user, password, callback);
});
},

/**
* @return Promise
*/
logout: function() {
var driver = this && this.driver || browser && browser.driver;
return driver.executeScriptAsync(function() {
var callback = arguments[arguments.length - 1];
Meteor.logout(callback);
});
},

/**
* @return Promise
*/
userId: function() {
var driver = this && this.driver || browser && browser.driver;
return driver.executeScript(function() {
return Meteor.userId();
});
},

/**
* @return Promise
*/
user: function() {
var driver = this && this.driver || browser && browser.driver;
return driver.executeScript(function() {
return Meteor.user();
});
}

};
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "meteor-storm",
"description": "WebDriver E2E test wrapper for Meteor.",
"version": "0.1.2",
"version": "0.1.3",
"homepage": "https://github.com/JamesMGreene/meteor-storm",
"license": "MIT",
"keywords": [
Expand Down
3 changes: 1 addition & 2 deletions referenceConf.js
Expand Up @@ -80,8 +80,7 @@ exports.config = {
// with relative paths will be prepended with this.
baseUrl: 'http://localhost:8000',

// Selector for the element housing the angular app - this defaults to
// body, but is necessary if ng-app is on a descendant of <body>
// Selector for the element housing the Meteor app - this defaults to body
rootElement: 'body',

// A callback function called once storm is ready and available, and
Expand Down

0 comments on commit f232e2a

Please sign in to comment.