Skip to content
This repository has been archived by the owner on Aug 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #49 from mobify/release-v1.5.0
Browse files Browse the repository at this point in the history
Release v1.5.0
  • Loading branch information
Marlow Payne committed Jan 29, 2016
2 parents 604510e + 627bc62 commit 17df279
Show file tree
Hide file tree
Showing 19 changed files with 219 additions and 177 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
1.5.0
- Follow company practices for tools and gitflow
- Have CircleCI lint our source code (TODO: tests to be fixed later)
- Update JS linting to current standards (grunt-eslint ^17.0.0 & mobify-code-style ^2.3.6)
- Fine tune linting targets to capture as much source code as feasible
- Introduces the command `waitForUrlToContain`
1.4.0
- Introduces the command `waitForUrl`
1.3.2
- Fixes a bug introduced in 1.3.1 with the refactoring of the preview command. The bug affected tests that used a key other than before/beforeEach to refer to the set up steps of a test, and in which preview was called more than once.
1.3.1
- Make site.json optional
1.3.0
- Update Selenium and Chrome Drivers (2.48.2 & 2.20)
1.2.0
- htmlCapture command to get/update fixtures
1.1.1
- Downgrade Chromedriver to 2.12
1.1.0
- Bumps Selenium server to 2.45
- Bumps Chromedriver to 2.15
1.0.0
- Reformatting and initial v1 release
46 changes: 19 additions & 27 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,31 @@
module.exports = function(grunt) {
var targets = [
'Gruntfile.js',
'assertions/**/*.js',
'commands/**/*.js',
'tests/src/*.js',
'!tests/nightwatch.js',
'!tests/run_tests.js',
'!tests/node_modules/**'
'*.js',
'**/*.js',
'!node_modules/**',
'!tests/node_modules/**',
'!selenium/**'
];

var excludes = [

];

grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-jscs-checker');
grunt.loadNpmTasks('grunt-eslint');

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
all: {
src: grunt.option('file') || targets,
eslint: {
dev: {
src: targets,
options: {
force: true,
ignores: excludes,
jshintrc: 'node_modules/mobify-code-style/javascript/.jshintrc'
reset: true,
config: require.resolve('mobify-code-style/javascript/.eslintrc')
}
}
},
jscs: {
options: {
config: 'node_modules/mobify-code-style/javascript/.jscsrc',
excludeFiles: excludes
},
src: targets
prod: {
src: targets,
options: {
reset: true,
config: require.resolve('mobify-code-style/javascript/.eslintrc-prod')
}
}
}
});

Expand All @@ -50,5 +42,5 @@ module.exports = function(grunt) {
});
});

grunt.registerTask('lint', ['jshint:all', 'jscs:src']);
grunt.registerTask('lint', ['eslint:prod']);
};
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,13 @@ nightwatch-commands

A set of Mobify specific custom commands for Nightwatch.js

http://adaptivejs.mobify.com/v2.0/docs/custom-nightwatchjs-api/
Full Documentation: http://adaptivejs.mobify.com/v2.0/docs/custom-nightwatchjs-api/

### Download
To begin, clone this repository. `cd` into your chosen folder, and run the following:
`npm install`

### Linting
JavaScript in this tool is linted with [ESLint](http://eslint.org/) according to our code [syntax and style standards](https://github.com/mobify/mobify-code-style) here at Mobify.

Linting may be run with the `grunt lint` command. Code is also linted automatically on [CircleCI](https://circleci.com/).
12 changes: 6 additions & 6 deletions assertions/elementsPresent.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ var async = require('async'),
util = require('util'),
events = require('events');

function Assertion() {
var Assertion = function() {
events.EventEmitter.call(this);
this.cb = null;
this.abortOnFailure = true;
this.selector = null;
}
};

util.inherits(Assertion, events.EventEmitter);

Expand Down Expand Up @@ -51,7 +51,7 @@ Assertion.prototype.checkElements = function() {
var found = [];
var selectors = this.selectors;

function checkElement(selector, cb) {
var checkElement = function(selector, cb) {
self.api.element.call(self, self.client.locateStrategy, selector, function(result) {
var value;

Expand All @@ -67,9 +67,9 @@ Assertion.prototype.checkElements = function() {

cb();
});
}
};

function returnResults(err) {
var returnResults = function(err) {
var result = missing.length;
var msg, passed;

Expand All @@ -87,7 +87,7 @@ Assertion.prototype.checkElements = function() {
self.client.assertion(passed, result, 0, msg, false);
self.cb(result);
self.emit('complete');
}
};

async.each(selectors, checkElement, returnResults);
};
Expand Down
12 changes: 6 additions & 6 deletions assertions/elementsVisible.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ var async = require('async'),
util = require('util'),
events = require('events');

function Assertion() {
var Assertion = function() {
events.EventEmitter.call(this);
this.cb = null;
this.abortOnFailure = true;
this.selector = null;
}
};

util.inherits(Assertion, events.EventEmitter);

Expand All @@ -50,7 +50,7 @@ Assertion.prototype.checkElements = function() {
var found = [];
var selectors = this.selectors;

function checkElement(selector, cb) {
var checkElement = function(selector, cb) {
self.api.isVisible.call(self, selector, function(result) {
var value;

Expand All @@ -66,9 +66,9 @@ Assertion.prototype.checkElements = function() {

cb();
});
}
};

function returnResults(err) {
var returnResults = function(err) {
var result = missing.length;
var msg, passed;

Expand All @@ -86,7 +86,7 @@ Assertion.prototype.checkElements = function() {
self.client.assertion(passed, result, 0, msg, false);
self.cb(result);
self.emit('complete');
}
};

async.each(selectors, checkElement, returnResults);
};
Expand Down
4 changes: 2 additions & 2 deletions assertions/templateName.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
var util = require('util'),
events = require('events');

function Assertion() {
var Assertion = function() {
events.EventEmitter.call(this);
this.cb = null;
this.abortOnFailure = true;
this.expected = null;
}
};

util.inherits(Assertion, events.EventEmitter);

Expand Down
30 changes: 15 additions & 15 deletions commands/htmlCapture.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ var mkdirp = require('mkdirp');
var mkdirpSync = function(path) {
try {
mkdirp.sync(path);
} catch(e) {
if ( e.code != 'EEXIST' ) throw e;
} catch (e) {
if ( e.code !== 'EEXIST' ) throw e;
}
}
};

exports.command = function(fileName, callback) {
if (fileName && typeof fileName !== 'string') {
Expand All @@ -17,19 +17,19 @@ exports.command = function(fileName, callback) {

var htmlCheck = /^\w+\.html$/;

if (!htmlCheck.test(fileName)){
if (!htmlCheck.test(fileName)) {
throw new Error('htmlCapture expects first parameter to be camelCased alphanumeric string ending with ".html"');
}

var client = this;
var filePath = "tests/fixtures/";
var filePath = 'tests/fixtures/';
var fileLocation = filePath + fileName;
var messages = {
success: 'Wrote HTML fixture to ' + fileLocation + ' after ',
failure: 'Failed to write HTML fixture after '
};
success: 'Wrote HTML fixture to ' + fileLocation + ' after ',
failure: 'Failed to write HTML fixture after '
};

client.source(function (result){
client.source(function(result) {
// Source will be stored in result.value. IE:
// console.log(result.value);

Expand All @@ -38,11 +38,11 @@ exports.command = function(fileName, callback) {

// Now save result.value to "../../fixtures/contact.html" in order to update the fixture.
fs.writeFile(fileLocation, result.value, function(error) {
if (error) {
console.error("write error: " + error.message);
} else {
console.log("Successful Write to " + fileLocation);
}
if (error) {
console.error('Write error: ' + error.message);
} else {
console.log('Successful write to ' + fileLocation);
}
});
});
};
};
6 changes: 3 additions & 3 deletions commands/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* argument when you call preview(). Upon completion, waitUntilMobified
* is called, to be sure that the adaptation is complete.
*
* If `site.json` does not exist, this command will just go to the specified URL.
* If `site.json` does not exist, this command will just go to the specified URL.
*
* ```
* this.demoTest = function (client) {
Expand Down Expand Up @@ -40,7 +40,7 @@ var qs = require('querystring');
exports.command = function(url, callback) {
var browser = this;

if (siteConfig) {
if (siteConfig) {
var site = siteConfig.profiles[siteConfig.activeProfile];

if (typeof url === 'function') {
Expand Down Expand Up @@ -87,4 +87,4 @@ exports.command = function(url, callback) {
}
});
}
};
};
4 changes: 2 additions & 2 deletions commands/waitForAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ var events = require('events');
* @api commands
*/

function WaitForAnimation() {
var WaitForAnimation = function() {
events.EventEmitter.call(this);
}
};

util.inherits(WaitForAnimation, events.EventEmitter);

Expand Down
4 changes: 2 additions & 2 deletions commands/waitForCondition.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
var util = require('util'),
events = require('events');

function CommandAction() {
var CommandAction = function() {
events.EventEmitter.call(this);
this.startTimer = null;
this.cb = null;
this.ms = null;
this.selector = null;
this.protocol = require('nightwatch/lib/api/protocol.js')(this.client);
}
};

util.inherits(CommandAction, events.EventEmitter);

Expand Down
6 changes: 3 additions & 3 deletions commands/waitForUrl.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
var util = require('util'),
events = require('events');

function WaitForUrl() {
var WaitForUrl = function() {
events.EventEmitter.call(this);
this.startTimer = null;
this.cb = null;
this.ms = null;
this.selector = null;
this.protocol = require('nightwatch/lib/api/protocol.js')(this.client);
}
};

util.inherits(WaitForUrl, events.EventEmitter);

Expand Down Expand Up @@ -57,7 +57,7 @@ WaitForUrl.prototype.check = function() {

this.protocol.url(function(result) {
var now = new Date().getTime();

if (result.status === 0 && result.value === self.url) {
setTimeout(function() {
var msg = self.messages.success + (now - self.startTimer) + ' milliseconds.';
Expand Down
Loading

0 comments on commit 17df279

Please sign in to comment.