forked from jsdom/jsdom
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break apart test options, runner and display
For jsdom#711, the test runner will execute in a web worker, but test results will be displayed in the parent page or a shell. So, it is convenient to break the options parsing, test running, and results display into their own modules for reuse by other runners.
- Loading branch information
Showing
4 changed files
with
250 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
var EventEmitter = require('events').EventEmitter; | ||
var nodeunit = require('nodeunit'); | ||
|
||
var assert = require('nodeunit/lib/assert'); | ||
|
||
assert.equal = function equal(actual, expected, message) { | ||
if (actual != expected) { | ||
if (actual && actual.nodeType) { | ||
actual = actual.toString(); | ||
} | ||
|
||
if (expected && expected.nodeType) { | ||
expected = expected.toString(); | ||
} | ||
|
||
assert.fail(actual, expected, message, '==', assert.equal); | ||
} | ||
}; | ||
|
||
assert.domSame = function(actual, expected, message) { | ||
if(expected != actual) { | ||
assert.equal(expected.nodeType, actual.nodeType); | ||
assert.equal(expected.nodeValue, actual.nodeValue); | ||
} | ||
}; | ||
|
||
module.exports = function runModules(toRun) { | ||
var emitter = new EventEmitter(); | ||
|
||
process.nextTick(function () { | ||
nodeunit.runModules(toRun, { | ||
moduleStart: function (name) { | ||
emitter.emit('moduleStart', name); | ||
}, | ||
moduleDone: function (name, assertions) { | ||
emitter.emit('moduleDone', name, assertions); | ||
}, | ||
testStart: function (name) { | ||
emitter.emit('testStart', name); | ||
}, | ||
testReady: function (name) { | ||
emitter.emit('testReady', name); | ||
}, | ||
testDone: function (test, assertions) { | ||
emitter.emit('testDone', test, assertions); | ||
}, | ||
log: function (assertion) { | ||
emitter.emit('log', assertion); | ||
}, | ||
done: function (assertions) { | ||
emitter.emit('done', assertions); | ||
} | ||
}); | ||
}); | ||
|
||
return emitter; | ||
}; |
Oops, something went wrong.