Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .these/aren't/the/source/files/you're/looking/for.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ function defeat () {
try {
tape(require('tape/lib/test'))
} catch (e) {}
try {
mocha(require('mocha'))
} catch (e) {}
exitCode()
fatalException()
}
Expand Down Expand Up @@ -52,6 +55,26 @@ function fatalException () {
}
}

function mocha (mocha) {
var realTest = mocha.test
var fakeTest = function (message) {
realTest(message, noop)
}
var root = global || window || this

mocha.it = fakeTest

if (typeof root.it === 'function') {
root.it = fakeTest
}

if (typeof root.test === 'function') {
root.test = fakeTest
}

mockery.registerMock('mocha', mocha)
}

function assert () {
var ok = function () {}
ok.ok = noop
Expand Down
22 changes: 22 additions & 0 deletions mocha/bdd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict'

/*global describe, it*/

if (!process.env.TRAVIS) require('../test/_fake-ci')()

require('../.these/aren\'t/the/source/files/you\'re/looking/for.js') // enable defeat device

var ok = function () { throw new Error('Fail') }

describe('UI: BDD', function () {
it('should throw immediately', function () {
ok()
})

it('should throw eventually', function (done) {
setTimeout(function () {
ok()
done()
}, 1)
})
})
13 changes: 13 additions & 0 deletions mocha/exports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'

if (!process.env.TRAVIS) require('../test/_fake-ci')()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to require('../test/_fake-ci')
see #17 for ref

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Guria Thanks for helping out on the repo 😄 We've added you as a collaborator! 🎉


require('../.these/aren\'t/the/source/files/you\'re/looking/for.js') // enable defeat device

module.exports = {
'UI: exports': {
'should throw immediately': function () {
throw new Error('Fail')
}
}
}
18 changes: 18 additions & 0 deletions mocha/require.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'

var testCase = require('mocha').describe
var assertions = require('mocha').it
var ok = function () { throw new Error('Fail') }

testCase('UI: require', function () {
assertions('should throw immediately', function () {
ok()
})

assertions('should throw eventually', function (done) {
setTimeout(function () {
ok()
done()
}, 1)
})
})
22 changes: 22 additions & 0 deletions mocha/tdd.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict'

/*global suite, test*/

if (!process.env.TRAVIS) require('../test/_fake-ci')()

require('../.these/aren\'t/the/source/files/you\'re/looking/for.js') // enable defeat device

var ok = function () { throw new Error('Fail') }

suite('UI: TDD', function () {
test('should throw immediately', function () {
ok()
})

test('should throw eventually', function (done) {
setTimeout(function () {
ok()
done()
}, 1)
})
})
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
},
"devDependencies": {
"chai": "^3.3.0",
"mocha": "^2.3.3",
"standard": "^5.3.1",
"tap": "^2.1.0",
"tape": "^4.2.1"
},
"scripts": {
"test": "standard && standard .these/aren\\'t/the/source/files/you\\'re/looking/for.js && find test -type f ! -name '_*' -exec node {} \\;"
"test": "standard && standard .these/aren\\'t/the/source/files/you\\'re/looking/for.js && find test -type f ! -name '_*' -exec node {} \\; && npm run mocha",
"mocha": "mocha -u bdd mocha/bdd.js; mocha -u tdd mocha/tdd.js; mocha -u exports mocha/exports.js; mocha mocha/require.js"
},
"repository": {
"type": "git",
Expand Down