Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

now works with testling!

  • Loading branch information...
commit ea21821119928ab33aa7264af1a97b3a3d0962a7 1 parent 48e3296
@substack authored
Showing with 34 additions and 16 deletions.
  1. +30 −11 harness.js
  2. +2 −2 mocha.js
  3. +2 −3 test.sh
View
41 harness.js
@@ -1,15 +1,22 @@
-function assert(expr, msg) {
+require.load('./mocha.js');
+
+window.assert = function (expr, msg) {
if (!expr) throw new Error(msg || 'failed');
}
var suite = new mocha.Suite;
+mocha.interfaces.bdd(suite);
+suite.emit('pre-require', window);
+
var utils = mocha.utils;
-var Reporter = function (runner) {
- var push = require('/push');
+var push = require('/push');
+function Reporter (runner) {
mocha.reporters.Base.call(this, runner);
runner.on('fail', function (test, err) {
+ push('log', { message : 'fail!' });
+
push('assert', {
type : 'fail',
ok : false,
@@ -21,6 +28,8 @@ var Reporter = function (runner) {
});
runner.on('pass', function (test) {
+ push('log', { message : 'pass!' });
+
push('assert', {
type : 'ok',
ok : true,
@@ -30,27 +39,37 @@ var Reporter = function (runner) {
});
});
+ runner.on('test end', function () {
+ push('log', { message : 'start!' });
+ });
+
runner.on('test end', function (test) {
+ push('log', { message : 'test end' });
push('testEnd', {});
});
runner.on('suite', function (suite) {
- push('testBegin', { name : test.fullName() });
+ push('log', { message : 'suite begin' });
+ push('testBegin', { name : Object.keys(suite) });
});
runner.on('suite end', function (suite) {
+ push('log', { message : 'suite end' });
push('end', {});
});
- push('end', {});
-};
-
-mocha.interfaces.bdd(suite);
-suite.emit('pre-require', window);
+ push('log', { message : 'test log' });
+ setTimeout(function () {
+ push('end', {});
+ }, 1000);
+}
+Reporter.prototype = new(mocha.reporters.Base);
-process.nextTick(function () {
+setTimeout(function () {
suite.emit('run');
var runner = new mocha.Runner(suite);
var reporter = new Reporter(runner);
runner.run();
-});
+}, 1);
+
+require.load('./test.js');
View
4 mocha.js
@@ -70,7 +70,7 @@ exports.EventEmitter = EventEmitter;
*/
function isArray(obj) {
- return '[object Array]' == {}.toString.call(obj);
+ return '[object Array]' == ({}).toString.call(obj);
}
/**
@@ -3223,4 +3223,4 @@ window.mocha = require('mocha');
return runner.run();
};
})();
-})();
+})();
View
5 test.sh
@@ -1,6 +1,5 @@
#!/bin/bash
-cat mocha.js harness.js array.js |
+tar -cf- mocha.js harness.js test.js |
@Raynos
Raynos added a note

test.js is not in repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
curl -sSNT- -u substack@gmail.com \
- 'http://testling.com/?browsers=chrome/canary&noinstrument'
-
+ 'http://testling.com/?browsers=chrome/canary&noinstrument=mocha.js&main=harness.js'
Please sign in to comment.
Something went wrong with that request. Please try again.