Skip to content

Commit

Permalink
Update to Intern 2.0 and improve functional test scaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanforbes committed Aug 17, 2014
1 parent 1aab10a commit 2f0ddfc
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 27 deletions.
1 change: 1 addition & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ DojoGenerator.prototype.appPackage = function appPackage() {
this.template('src/app/tests/dojoConfig.js', appPath + '/tests/dojoConfig.js');
this.template('src/app/tests/intern.js', appPath + '/tests/intern.js');
this.template('src/app/tests/ready.js', appPath + '/tests/ready.js');
this.template('src/app/tests/remoteReady.js', appPath + '/tests/remoteReady.js');
};

DojoGenerator.prototype.runtime = function runtime() {
Expand Down
18 changes: 9 additions & 9 deletions app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"name": "<%= appname %>",
"version": "0.0.0",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-dojo": "~0.2.4",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-clean": "~0.5.0",<% if (stylus) { %>
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-stylus": "~0.8.0",<% } %>
"intern-geezer": "~1.3.2",
"load-grunt-tasks": "~0.1.0"
"grunt": "0.4.1",
"grunt-dojo": "0.2.4",
"grunt-contrib-copy": "0.4.1",
"grunt-contrib-connect": "0.5.0",
"grunt-contrib-clean": "0.5.0",<% if (stylus) { %>
"grunt-contrib-watch": "0.5.3",
"grunt-contrib-stylus": "0.8.0",<% } %>
"intern-geezer": "2.0.2",
"load-grunt-tasks": "0.1.0"
}
}
17 changes: 8 additions & 9 deletions app/templates/src/app/tests/intern.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ define({
// Note that the `build` capability will be filled in with the current commit ID from the Travis CI environment
// automatically
capabilities: {
'selenium-version': '2.37.0'
'selenium-version': '2.41.0'
},

// Browsers to run integration testing against. Note that version numbers must be strings if used with Sauce
Expand All @@ -33,15 +33,14 @@ define({
// Maximum number of simultaneous integration tests that should be executed on the remote WebDriver service
maxConcurrency: 3,

// Whether or not to start Sauce Connect before running tests
useSauceConnect: true,
// Name of the tunnel class to use for WebDriver tests
tunnel: 'SauceLabsTunnel',

// Connection information for the remote WebDriver service. If using Sauce Labs, keep your username and password
// in the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables unless you are sure you will NEVER be
// publishing this configuration file somewhere
webdriver: {
host: 'localhost',
port: 4444
// The desired AMD loader to use when running unit tests (client.html/client.js). Omit to use the default Dojo
// loader
useLoader: {
'host-node': 'dojo/dojo',
'host-browser': 'node_modules/dojo/dojo.js'
},

// Configuration options for the module loader; any AMD configuration options supported by the Dojo loader can be
Expand Down
11 changes: 6 additions & 5 deletions app/templates/src/app/tests/ready.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var testReady = 0;
var __ready__ = false;
define([
'dojo/promise/all',
'dojo/Deferred',
Expand All @@ -12,6 +12,9 @@ define([
return deferred;
}
};
function done() {
__ready__ = true;
}
var req = function (config, deps, callback) {
if (!callback) {
callback = deps;
Expand All @@ -27,11 +30,9 @@ define([
};
if (typeof window.initializeTest === 'function') {
window.initializeTest.call(context, req);
all(promises).then(function () {
testReady = 1;
});
all(promises).then(done);
}
else {
testReady = 1;
done();
}
});
20 changes: 20 additions & 0 deletions app/templates/src/app/tests/remoteReady.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
define([
'intern/dojo/node!leadfoot/helpers/pollUntil'
], function (pollUntil) {
/* global __ready__ */
function remoteReady(timeout) {
if (isNaN(timeout)) {
timeout = 5000;
}
return pollUntil(
function () {
if (typeof __ready__ !== 'undefined') {
return __ready__ || null;
}
},
timeout == null ? 5000 : timeout
);
}

return remoteReady;
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"yeoman-generator": "~0.13.0"
},
"devDependencies": {
"intern": "~1.3.2"
"intern": "2.0.2"
},
"peerDependencies": {
"yo": ">=1.0.0-rc.1"
Expand Down
8 changes: 5 additions & 3 deletions test/templates/functional.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
define([
'intern!object',
'intern/chai!assert',
'<%= appname %>/tests/remoteReady',
'require'
], function (registerSuite, assert, require) {
], function (registerSuite, assert, remoteReady, require) {
registerSuite({
name: '<%= name %>',

setup: function () {
return this.get('remote').get(require.toUrl('./<%= name %>.html'))
.waitForCondition('!!testReady', 5000);
return this.get('remote')
.get(require.toUrl('./<%= name %>.html'))
.then(remoteReady());
}
});
});

0 comments on commit 2f0ddfc

Please sign in to comment.