Skip to content

Commit

Permalink
Upgrade qunitjs to 2.3.0 (#123)
Browse files Browse the repository at this point in the history
Update test files to use new non-global QUnit syntax.
Update bridge between this grunt plugin and phantomjs:
* Remove deprecated autorun QUnit option.
Update devDependency qunitjs to 2.3.0.
Update Gruntfile to account for failed tests.
  • Loading branch information
mkucko authored and Arkni committed Mar 29, 2017
1 parent f28e09d commit 353a7a8
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
10 changes: 7 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,12 @@ module.exports = function(grunt) {
currentUrl = url;
if (!successes[currentUrl]) { successes[currentUrl] = 0; }
});
grunt.event.on('qunit.done', function(failed, passed) {
if (failed === 0 && passed === 2) { successes[currentUrl]++; }
grunt.event.on('qunit.done', function(failed, passed, total) {
if (failed === 0 && passed === total) {
successes[currentUrl]++;
} else {
successes[currentUrl] -= 100;
}
});

grunt.registerTask('really-test', 'Test to see if qunit task actually worked.', function() {
Expand All @@ -117,7 +121,7 @@ module.exports = function(grunt) {
'test/qunit1.html': 3,
'test/qunit2.html': 3,
'http://localhost:9000/test/qunit1.html': 2,
'http://localhost:9000/test/qunit3.html?foo=bar&noglobals=true': 1,
'http://localhost:9000/test/qunit3.html?foo=bar&noglobals=true': -100,
'http://localhost:9000/test/qunit4.html' : 1,
'http://localhost:9000/test/qunit5.html' : 1
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"grunt-contrib-internal": "^1.1.0",
"grunt-contrib-jshint": "^1.0.0",
"grunt-shell": "^1.3.0",
"qunitjs": "^1.20.0"
"qunitjs": "^2.3.0"
},
"keywords": [
"gruntplugin"
Expand Down
2 changes: 0 additions & 2 deletions phantomjs/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

// Don't re-order tests.
QUnit.config.reorder = false;
// Run tests serially, not in parallel.
QUnit.config.autorun = false;

// Send messages to the parent PhantomJS process via alert! Good times!!
function sendMessage() {
Expand Down
16 changes: 8 additions & 8 deletions test/qunit_modules.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module('module1');
QUnit.module('module1');

test('basic test', function() {
expect(1);
ok(true, 'this had better work.');
QUnit.test('basic test', function(assert) {
assert.expect(1);
assert.ok(true, 'this had better work.');
});


module('module2');
QUnit.module('module2');

test('a second basic test', function() {
expect(1);
ok(true, 'this had better work.');
QUnit.test('a second basic test', function(assert) {
assert.expect(1);
assert.ok(true, 'this had better work.');
});
18 changes: 8 additions & 10 deletions test/qunit_noglobal_test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@

var pushFailure = QUnit.pushFailure;
var failures = [];
QUnit.log(function( details ) {
if (details.result === false)
failures.push(details.message);
});

test('global pollution', function(assert) {
QUnit.todo('global pollution', function(assert) {
window.pollute = true;
assert.ok(pollute, 'nasty pollution');
QUnit.pushFailure = function(message) {
failures.push(message);
};
});

test('actually check for global pollution', function() {
expect(1);
QUnit.pushFailure = pushFailure;
deepEqual(failures, ['Introduced global variable(s): pollute']);
QUnit.test('actually check for global pollution', function(assert) {
assert.expect(1);
assert.deepEqual(failures, ['Introduced global variable(s): pollute']);
});
12 changes: 6 additions & 6 deletions test/qunit_test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

test('basic test', function() {
expect(1);
ok(true, 'this had better work.');
QUnit.test('basic test', function(assert) {
assert.expect(1);
assert.ok(true, 'this had better work.');
});


test('can access the DOM', function() {
expect(1);
QUnit.test('can access the DOM', function(assert) {
assert.expect(1);
var fixture = document.getElementById('qunit-fixture');
equal(fixture.innerText, 'this had better work.', 'should be able to access the DOM.');
assert.equal(fixture.innerText, 'this had better work.', 'should be able to access the DOM.');
});
12 changes: 6 additions & 6 deletions test/qunit_test_error.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

test('basic test', function() {
expect(1);
ok(0, 'this had better work.');
QUnit.test('basic test', function(assert) {
assert.expect(1);
assert.ok(0, 'this had better work.');
});


test('can access the DOM', function() {
expect(1);
QUnit.test('can access the DOM', function(assert) {
assert.expect(1);
var fixture = document.getElementById('qunit-fixture');
equal(fixture.innerText, 'this had better work.', 'should be able to access the DOM.');
assert.equal(fixture.innerText, 'this had better work.', 'should be able to access the DOM.');
});

0 comments on commit 353a7a8

Please sign in to comment.