Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Aubry <mattab@users.noreply.github.com>2017-04-26 09:52:46 +0300
committerGitHub <noreply@github.com>2017-04-26 09:52:46 +0300
commit317700513cc732bb2371edbe645555feadbbc545 (patch)
treeefc28c578903563cd72d8436dbefcec32ab161c7 /tests/lib/mocha-3.1.2/test/integration
parentbc8222d451337185db343486319af6782b009148 (diff)
parent199e43ef5809d09803416db72ce0ace6c9a4d895 (diff)
Merge pull request #11651 from piwik/3.x-dev3.0.4-b1
Release Piwik 3.0.4-b1
Diffstat (limited to 'tests/lib/mocha-3.1.2/test/integration')
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/diffs.spec.js46
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/cascade.fixture.js59
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.css.in9
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.css.out13
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.fixture.js113
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/output91
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/after-hook-async-error.fixture.js21
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/after-hook-error.fixture.js19
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/afterEach-hook-async-error.fixture.js21
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/afterEach-hook-error.fixture.js19
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-async-error-tip.fixture.js13
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-async-error.fixture.js21
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-error-tip.fixture.js11
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-error.fixture.js19
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/beforeEach-hook-async-error.fixture.js21
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/beforeEach-hook-error.fixture.js19
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/multiple-hook-async-error.fixture.js141
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/multiple-hook-error.fixture.js131
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-before.fixture.js12
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-beforeEach.fixture.js16
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-specs.fixture.js12
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done.fixture.js20
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/options/async-only-async.fixture.js5
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/options/async-only-sync.fixture.js3
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/options/bail.fixture.js23
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/options/delay-fail.fixture.js8
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/options/delay.fixture.js16
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/options/grep.fixture.js19
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/bdd.fixture.js72
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/qunit.fixture.js27
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/tdd.fixture.js37
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/options/retries.fixture.js7
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/options/sort-alpha.fixture.js9
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/options/sort-beta.fixture.js7
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/passing.fixture.js13
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-before.fixture.js18
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-beforeEach.fixture.js18
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-spec.fixture.js14
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-before.fixture.js15
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-beforeEach.fixture.js15
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-spec.fixture.js12
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/pending/spec.fixture.js5
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/regression/1794/issue-1794.fixture.js5
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/regression/1794/simple-ui.js28
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1327.fixture.js17
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1417.js22
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1991.fixture.js49
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2315.js11
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2406.fixture.js17
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2417.fixture.js9
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/retries/async.fixture.js30
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/retries/early-pass.fixture.js13
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/retries/hooks.fixture.js27
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/retries/nested.fixture.js11
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-no-callback.fixture.js3
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-skipped-callback.fixture.js3
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-skipped-no-callback.fixture.js3
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/timeout.fixture.js19
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/uncaught-hook.fixture.js15
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/fixtures/uncaught.fixture.js22
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/helpers.js193
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/hook-err.spec.js217
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/hooks.spec.js45
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/multiple-done.spec.js98
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/only.spec.js45
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/options.spec.js183
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/pending.spec.js102
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/regression.spec.js119
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/reporters.spec.js63
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/retries.spec.js108
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/suite.spec.js43
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/timeout.spec.js18
-rw-r--r--tests/lib/mocha-3.1.2/test/integration/uncaught.spec.js37
73 files changed, 2765 insertions, 0 deletions
diff --git a/tests/lib/mocha-3.1.2/test/integration/diffs.spec.js b/tests/lib/mocha-3.1.2/test/integration/diffs.spec.js
new file mode 100644
index 0000000000..7d620e7489
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/diffs.spec.js
@@ -0,0 +1,46 @@
+'use strict';
+
+var assert = require('assert');
+var helpers = require('./helpers');
+var run = helpers.runMocha;
+var fs = require('fs');
+var getDiffs = helpers.getDiffs;
+
+function getExpectedOutput () {
+ var output = fs.readFileSync('test/integration/fixtures/diffs/output', 'UTF8');
+
+ // Diffs are delimited in file by "// DIFF"
+ return output.split(/\s*\/\/ DIFF/).slice(1).map(function (diff) {
+ return diff.split('\n').filter(Boolean).join('\n');
+ });
+}
+
+describe('diffs', function () {
+ var diffs, expected;
+
+ before(function (done) {
+ run('diffs/diffs.fixture.js', ['-C'], function (err, res) {
+ expected = getExpectedOutput();
+ diffs = getDiffs(res.output);
+ done(err);
+ });
+ });
+
+ [
+ 'should display a diff for small strings',
+ 'should display a diff of canonicalized objects',
+ 'should display a diff for medium strings',
+ 'should display a diff for entire object dumps',
+ 'should display a diff for multi-line strings',
+ 'should display a diff for entire object dumps',
+ 'should display a full-comparison with escaped special characters',
+ 'should display a word diff for large strings',
+ 'should work with objects',
+ 'should show value diffs and not be affected by commas',
+ 'should display diff by data and not like an objects'
+ ].forEach(function (title, i) {
+ it(title, function () {
+ assert.equal(diffs[i], expected[i]);
+ });
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/cascade.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/cascade.fixture.js
new file mode 100644
index 0000000000..259c81af2d
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/cascade.fixture.js
@@ -0,0 +1,59 @@
+'use strict';
+
+describe('one', function () {
+ before(function () {
+ console.log('before one');
+ });
+
+ after(function () {
+ console.log('after one');
+ });
+
+ beforeEach(function () {
+ console.log(' before each one');
+ });
+
+ afterEach(function () {
+ console.log(' after each one');
+ });
+
+ describe('two', function () {
+ before(function () {
+ console.log(' before two');
+ });
+
+ after(function () {
+ console.log(' after two');
+ });
+
+ beforeEach(function () {
+ console.log(' before each two');
+ });
+
+ afterEach(function () {
+ console.log(' after each two');
+ });
+
+ describe('three', function () {
+ before(function () {
+ console.log(' before three');
+ });
+
+ after(function () {
+ console.log(' after three');
+ });
+
+ beforeEach(function () {
+ console.log(' before each three');
+ });
+
+ afterEach(function () {
+ console.log(' after each three');
+ });
+
+ it('should three', function () {
+ console.log(' TEST three');
+ });
+ });
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.css.in b/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.css.in
new file mode 100644
index 0000000000..09a3ca5363
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.css.in
@@ -0,0 +1,9 @@
+body {
+ font: "Helvetica Neue", Helvetica, arial, sans-serif;
+ background: black;
+ color: white;
+}
+
+a {
+ color: blue
+}
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.css.out b/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.css.out
new file mode 100644
index 0000000000..53b3ec906e
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.css.out
@@ -0,0 +1,13 @@
+body {
+ font: "Helvetica Neue", Helvetica, arial, sans-serif;
+ background: black;
+ color: #fff;
+}
+
+a {
+ color: blue;
+}
+
+foo {
+ bar: 'baz';
+}
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.fixture.js
new file mode 100644
index 0000000000..50ea00bee0
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/diffs.fixture.js
@@ -0,0 +1,113 @@
+'use strict';
+
+var fs = require('fs');
+var cssin = fs.readFileSync('test/integration/fixtures/diffs/diffs.css.in', 'ascii');
+var cssout = fs.readFileSync('test/integration/fixtures/diffs/diffs.css.out', 'ascii');
+
+describe('diffs', function () {
+ var actual, expected;
+
+ it('should display a diff for small strings', function () {
+ actual = 'foo rar baz';
+ expected = 'foo bar baz';
+ actual.should.equal(expected);
+ });
+
+ it('should display a diff of canonicalized objects', function () {
+ actual = { name: 'travis j', age: 23 };
+ expected = { age: 23, name: 'travis' };
+ actual.should.equal(expected);
+ });
+
+ it('should display a diff for medium strings', function () {
+ actual = 'foo bar baz\nfoo rar baz\nfoo bar raz';
+ expected = 'foo bar baz\nfoo bar baz\nfoo bar baz';
+ actual.should.equal(expected);
+ });
+
+ it('should display a diff for entire object dumps', function () {
+ actual = {
+ name: 'joel',
+ age: 30,
+ address: {
+ city: 'new york',
+ country: 'usa'
+ }
+ };
+ expected = {
+ name: 'joe',
+ age: 30,
+ address: {
+ city: 'new york',
+ country: 'us'
+ }
+ };
+ actual.should.equal(expected);
+ });
+
+ it('should display a diff for multi-line strings', function () {
+ actual = 'one two three\nfour zzzz six\nseven eight nine';
+ expected = 'one two three\nfour five six\nseven eight nine';
+ actual.should.equal(expected);
+ });
+
+ it('should display a diff for entire object dumps', function () {
+ actual = {
+ name: 'joel',
+ age: 30,
+ address: {
+ city: 'new york',
+ country: 'usa'
+ }
+ };
+ expected = {
+ name: 'joe',
+ age: 30,
+ address: {
+ city: 'new york',
+ country: 'us'
+ }
+ };
+ actual.should.equal(expected);
+ });
+
+ it('should display a full-comparison with escaped special characters', function () {
+ actual = 'one\ttab\ntwo\t\t\ttabs';
+ expected = 'one\ttab\ntwo\t\ttabs';
+ actual.should.equal(expected);
+ });
+
+ it('should display a word diff for large strings', function () {
+ cssin.should.equal(cssout);
+ });
+
+ it('should work with objects', function () {
+ actual = {
+ name: 'tobi',
+ species: 'ferret',
+ color: 'white',
+ age: 2
+ };
+
+ expected = {
+ name: 'loki',
+ species: 'ferret',
+ color: 'brown',
+ age: 2
+ };
+
+ actual.should.eql(expected);
+ });
+
+ it('should show value diffs and not be affected by commas', function () {
+ actual = { a: 123 };
+ expected = { a: 123, b: 456 };
+ actual.should.equal(expected);
+ });
+
+ it('should display diff by data and not like an objects', function () {
+ actual = new Buffer([0x01]);
+ expected = new Buffer([0x02]);
+ actual.should.equal(expected);
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/output b/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/output
new file mode 100644
index 0000000000..bf56a96397
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/diffs/output
@@ -0,0 +1,91 @@
+// DIFF
+ -foo rar baz
+ +foo bar baz
+
+// DIFF
+ {
+ "age": 23
+ - "name": "travis j"
+ + "name": "travis"
+ }
+
+// DIFF
+ foo bar baz
+ -foo rar baz
+ -foo bar raz
+ +foo bar baz
+ +foo bar baz
+
+// DIFF
+ {
+ "address": {
+ "city": "new york"
+ - "country": "usa"
+ + "country": "us"
+ }
+ "age": 30
+ - "name": "joel"
+ + "name": "joe"
+ }
+
+// DIFF
+ one two three
+ -four zzzz six
+ +four five six
+ seven eight nine
+
+// DIFF
+ {
+ "address": {
+ "city": "new york"
+ - "country": "usa"
+ + "country": "us"
+ }
+ "age": 30
+ - "name": "joel"
+ + "name": "joe"
+ }
+
+// DIFF
+ one tab
+ -two tabs
+ +two tabs
+
+// DIFF
+ body {
+ font: "Helvetica Neue", Helvetica, arial, sans-serif;
+ background: black;
+ - color: white;
+ + color: #fff;
+ }
+
+ a {
+ - color: blue
+ + color: blue;
+ }
+ +
+ +foo {
+ + bar: 'baz';
+ +}
+
+// DIFF
+ {
+ "age": 2
+ - "color": "white"
+ - "name": "tobi"
+ + "color": "brown"
+ + "name": "loki"
+ "species": "ferret"
+ }
+
+// DIFF
+ {
+ "a": 123
+ + "b": 456
+ }
+
+// DIFF
+ [
+ - 1
+ + 2
+ ]
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/after-hook-async-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/after-hook-async-error.fixture.js
new file mode 100644
index 0000000000..f3dfe7e1ae
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/after-hook-async-error.fixture.js
@@ -0,0 +1,21 @@
+'use strict';
+
+describe('spec 1', function () {
+ after(function (done) {
+ console.log('after');
+ process.nextTick(function () {
+ throw new Error('after hook error');
+ });
+ });
+ it('should be called because error is in after hook', function () {
+ console.log('test 1');
+ });
+ it('should be called because error is in after hook', function () {
+ console.log('test 2');
+ });
+});
+describe('spec 2', function () {
+ it('should be called, because hook error was in a sibling suite', function () {
+ console.log('test 3');
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/after-hook-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/after-hook-error.fixture.js
new file mode 100644
index 0000000000..7fc258f46d
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/after-hook-error.fixture.js
@@ -0,0 +1,19 @@
+'use strict';
+
+describe('spec 1', function () {
+ after(function () {
+ console.log('after');
+ throw new Error('after hook error');
+ });
+ it('should be called because error is in after hook', function () {
+ console.log('test 1');
+ });
+ it('should be called because error is in after hook', function () {
+ console.log('test 2');
+ });
+});
+describe('spec 2', function () {
+ it('should be called, because hook error was in a sibling suite', function () {
+ console.log('test 3');
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/afterEach-hook-async-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/afterEach-hook-async-error.fixture.js
new file mode 100644
index 0000000000..442ad9321f
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/afterEach-hook-async-error.fixture.js
@@ -0,0 +1,21 @@
+'use strict';
+
+describe('spec 1', function () {
+ afterEach(function (done) {
+ console.log('after');
+ process.nextTick(function () {
+ throw new Error('after each hook error');
+ });
+ });
+ it('should be called because error is in after each hook', function () {
+ console.log('test 1');
+ });
+ it('should not be called', function () {
+ console.log('test 2');
+ });
+});
+describe('spec 2', function () {
+ it('should be called, because hook error was in a sibling suite', function () {
+ console.log('test 3');
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/afterEach-hook-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/afterEach-hook-error.fixture.js
new file mode 100644
index 0000000000..5fb9a36c8d
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/afterEach-hook-error.fixture.js
@@ -0,0 +1,19 @@
+'use strict';
+
+describe('spec 1', function () {
+ afterEach(function () {
+ console.log('after');
+ throw new Error('after each hook error');
+ });
+ it('should be called because error is in after each hook', function () {
+ console.log('test 1');
+ });
+ it('should not be called', function () {
+ console.log('test 2');
+ });
+});
+describe('spec 2', function () {
+ it('should be called, because hook error was in a sibling suite', function () {
+ console.log('test 3');
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-async-error-tip.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-async-error-tip.fixture.js
new file mode 100644
index 0000000000..04801c1946
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-async-error-tip.fixture.js
@@ -0,0 +1,13 @@
+'use strict';
+
+describe('spec 1', function () {
+ it('should not blame me', function () { });
+});
+describe('spec 2', function () {
+ before(function (done) {
+ process.nextTick(function () {
+ throw new Error('before hook error');
+ });
+ });
+ it('skipped');
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-async-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-async-error.fixture.js
new file mode 100644
index 0000000000..2530eec783
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-async-error.fixture.js
@@ -0,0 +1,21 @@
+'use strict';
+
+describe('spec 1', function () {
+ before(function (done) {
+ console.log('before');
+ process.nextTick(function () {
+ throw new Error('before hook error');
+ });
+ });
+ it('should not be called because of error in before hook', function () {
+ console.log('test 1');
+ });
+ it('should not be called because of error in before hook', function () {
+ console.log('test 2');
+ });
+});
+describe('spec 2', function () {
+ it('should be called, because hook error was in a sibling suite', function () {
+ console.log('test 3');
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-error-tip.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-error-tip.fixture.js
new file mode 100644
index 0000000000..64df731573
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-error-tip.fixture.js
@@ -0,0 +1,11 @@
+'use strict';
+
+describe('spec 1', function () {
+ it('should not blame me', function () { });
+});
+describe('spec 2', function () {
+ before(function () {
+ throw new Error('before hook error');
+ });
+ it('skipped');
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-error.fixture.js
new file mode 100644
index 0000000000..547e54a243
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/before-hook-error.fixture.js
@@ -0,0 +1,19 @@
+'use strict';
+
+describe('spec 1', function () {
+ before(function () {
+ console.log('before');
+ throw new Error('before hook error');
+ });
+ it('should not be called because of error in before hook', function () {
+ console.log('test 1');
+ });
+ it('should not be called because of error in before hook', function () {
+ console.log('test 2');
+ });
+});
+describe('spec 2', function () {
+ it('should be called, because hook error was in a sibling suite', function () {
+ console.log('test 3');
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/beforeEach-hook-async-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/beforeEach-hook-async-error.fixture.js
new file mode 100644
index 0000000000..6ce27784a6
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/beforeEach-hook-async-error.fixture.js
@@ -0,0 +1,21 @@
+'use strict';
+
+describe('spec 1', function () {
+ beforeEach(function (done) {
+ console.log('before');
+ process.nextTick(function () {
+ throw new Error('before each hook error');
+ });
+ });
+ it('should not be called because of error in before each hook', function () {
+ console.log('test 1');
+ });
+ it('should not be called because of error in before each hook', function () {
+ console.log('test 2');
+ });
+});
+describe('spec 2', function () {
+ it('should be called, because hook error was in a sibling suite', function () {
+ console.log('test 3');
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/beforeEach-hook-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/beforeEach-hook-error.fixture.js
new file mode 100644
index 0000000000..4c0ab2f237
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/beforeEach-hook-error.fixture.js
@@ -0,0 +1,19 @@
+'use strict';
+
+describe('spec 1', function () {
+ beforeEach(function () {
+ console.log('before');
+ throw new Error('before each hook error');
+ });
+ it('should not be called because of error in before each hook', function () {
+ console.log('test 1');
+ });
+ it('should not be called because of error in before each hook', function () {
+ console.log('test 2');
+ });
+});
+describe('spec 2', function () {
+ it('should be called, because hook error was in a sibling suite', function () {
+ console.log('test 3');
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/multiple-hook-async-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/multiple-hook-async-error.fixture.js
new file mode 100644
index 0000000000..858bbb3c5e
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/multiple-hook-async-error.fixture.js
@@ -0,0 +1,141 @@
+'use strict';
+
+before(function () {
+ console.log('root before');
+});
+beforeEach(function () {
+ console.log('root before each');
+});
+describe('1', function () {
+ beforeEach(function () {
+ console.log('1 before each');
+ });
+
+ describe('1-1', function () {
+ before(function () {
+ console.log('1-1 before');
+ });
+ beforeEach(function (done) {
+ console.log('1-1 before each');
+ process.nextTick(function () {
+ throw new Error('1-1 before each hook failed');
+ });
+ });
+ it('1-1 test 1', function () {
+ console.log('1-1 test 1');
+ });
+ it('1-1 test 2', function () {
+ console.log('1-1 test 2');
+ });
+ afterEach(function () {
+ console.log('1-1 after each');
+ });
+ after(function (done) {
+ console.log('1-1 after');
+ process.nextTick(function () {
+ throw new Error('1-1 after hook failed');
+ });
+ });
+ });
+
+ describe('1-2', function () {
+ before(function () {
+ console.log('1-2 before');
+ });
+ beforeEach(function () {
+ console.log('1-2 before each');
+ });
+ it('1-2 test 1', function () {
+ console.log('1-2 test 1');
+ });
+ it('1-2 test 2', function () {
+ console.log('1-2 test 2');
+ });
+ afterEach(function (done) {
+ console.log('1-2 after each');
+ process.nextTick(function () {
+ throw new Error('1-2 after each hook failed');
+ });
+ });
+ after(function () {
+ console.log('1-2 after');
+ });
+ });
+
+ afterEach(function () {
+ console.log('1 after each');
+ });
+
+ after(function () {
+ console.log('1 after');
+ });
+});
+
+describe('2', function () {
+ beforeEach(function (done) {
+ console.log('2 before each');
+ process.nextTick(function () {
+ throw new Error('2 before each hook failed');
+ });
+ });
+
+ describe('2-1', function () {
+ before(function () {
+ console.log('2-1 before');
+ });
+ beforeEach(function () {
+ console.log('2-1 before each');
+ });
+ it('2-1 test 1', function () {
+ console.log('2-1 test 1');
+ });
+ it('2-1 test 2', function () {
+ console.log('2-1 test 2');
+ });
+ afterEach(function () {
+ console.log('2-1 after each');
+ });
+ after(function () {
+ console.log('2-1 after');
+ });
+ });
+
+ describe('2-2', function () {
+ before(function () {
+ console.log('2-2 before');
+ });
+ beforeEach(function () {
+ console.log('2-2 before each');
+ });
+ it('2-2 test 1', function () {
+ console.log('2-2 test 1');
+ });
+ it('2-2 test 2', function () {
+ console.log('2-2 test 2');
+ });
+ afterEach(function () {
+ console.log('2-2 after each');
+ });
+ after(function () {
+ console.log('2-2 after');
+ });
+ });
+
+ afterEach(function (done) {
+ console.log('2 after each');
+ process.nextTick(function () {
+ throw new Error('2 after each hook failed');
+ });
+ });
+
+ after(function () {
+ console.log('2 after');
+ });
+});
+
+after(function () {
+ console.log('root after');
+});
+afterEach(function () {
+ console.log('root after each');
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/multiple-hook-error.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/multiple-hook-error.fixture.js
new file mode 100644
index 0000000000..085978ef79
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/hooks/multiple-hook-error.fixture.js
@@ -0,0 +1,131 @@
+'use strict';
+
+before(function () {
+ console.log('root before');
+});
+beforeEach(function () {
+ console.log('root before each');
+});
+describe('1', function () {
+ beforeEach(function () {
+ console.log('1 before each');
+ });
+
+ describe('1-1', function () {
+ before(function () {
+ console.log('1-1 before');
+ });
+ beforeEach(function () {
+ console.log('1-1 before each');
+ throw new Error('1-1 before each hook failed');
+ });
+ it('1-1 test 1', function () {
+ console.log('1-1 test 1');
+ });
+ it('1-1 test 2', function () {
+ console.log('1-1 test 2');
+ });
+ afterEach(function () {
+ console.log('1-1 after each');
+ });
+ after(function () {
+ console.log('1-1 after');
+ throw new Error('1-1 after hook failed');
+ });
+ });
+
+ describe('1-2', function () {
+ before(function () {
+ console.log('1-2 before');
+ });
+ beforeEach(function () {
+ console.log('1-2 before each');
+ });
+ it('1-2 test 1', function () {
+ console.log('1-2 test 1');
+ });
+ it('1-2 test 2', function () {
+ console.log('1-2 test 2');
+ });
+ afterEach(function () {
+ console.log('1-2 after each');
+ throw new Error('1-2 after each hook failed');
+ });
+ after(function () {
+ console.log('1-2 after');
+ });
+ });
+
+ afterEach(function () {
+ console.log('1 after each');
+ });
+
+ after(function () {
+ console.log('1 after');
+ });
+});
+
+describe('2', function () {
+ beforeEach(function () {
+ console.log('2 before each');
+ throw new Error('2 before each hook failed');
+ });
+
+ describe('2-1', function () {
+ before(function () {
+ console.log('2-1 before');
+ });
+ beforeEach(function () {
+ console.log('2-1 before each');
+ });
+ it('2-1 test 1', function () {
+ console.log('2-1 test 1');
+ });
+ it('2-1 test 2', function () {
+ console.log('2-1 test 2');
+ });
+ afterEach(function () {
+ console.log('2-1 after each');
+ });
+ after(function () {
+ console.log('2-1 after');
+ });
+ });
+
+ describe('2-2', function () {
+ before(function () {
+ console.log('2-2 before');
+ });
+ beforeEach(function () {
+ console.log('2-2 before each');
+ });
+ it('2-2 test 1', function () {
+ console.log('2-2 test 1');
+ });
+ it('2-2 test 2', function () {
+ console.log('2-2 test 2');
+ });
+ afterEach(function () {
+ console.log('2-2 after each');
+ });
+ after(function () {
+ console.log('2-2 after');
+ });
+ });
+
+ afterEach(function () {
+ console.log('2 after each');
+ throw new Error('2 after each hook failed');
+ });
+
+ after(function () {
+ console.log('2 after');
+ });
+});
+
+after(function () {
+ console.log('root after');
+});
+afterEach(function () {
+ console.log('root after each');
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-before.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-before.fixture.js
new file mode 100644
index 0000000000..1e1bc71a16
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-before.fixture.js
@@ -0,0 +1,12 @@
+'use strict';
+
+describe('suite', function () {
+ before(function (done) {
+ setTimeout(done, 10);
+ setTimeout(done, 30);
+ });
+
+ it('test1', function (done) {
+ setTimeout(done, 50);
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-beforeEach.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-beforeEach.fixture.js
new file mode 100644
index 0000000000..32de2bf442
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-beforeEach.fixture.js
@@ -0,0 +1,16 @@
+'use strict';
+
+describe('suite', function () {
+ beforeEach(function (done) {
+ setTimeout(done, 10);
+ setTimeout(done, 20);
+ });
+
+ it('test1', function (done) {
+ setTimeout(done, 50);
+ });
+
+ it('test2', function (done) {
+ setTimeout(done, 50);
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-specs.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-specs.fixture.js
new file mode 100644
index 0000000000..a8ae6d1ac4
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done-specs.fixture.js
@@ -0,0 +1,12 @@
+'use strict';
+
+describe('suite', function () {
+ it('test1', function (done) {
+ done();
+ setTimeout(done, 10);
+ });
+
+ it('test2', function (done) {
+ setTimeout(done, 20);
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done.fixture.js
new file mode 100644
index 0000000000..f1b471c678
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/multiple-done.fixture.js
@@ -0,0 +1,20 @@
+'use strict';
+
+// The suite below should result in an additional error, but does
+// not. Uncomment once this bug is resolved.
+
+// describe('suite', function() {
+// beforeEach(function(done) {
+// done();
+// done();
+// });
+
+// it('test', function() {});
+// });
+
+it('should fail in a test-case', function (done) {
+ process.nextTick(function () {
+ done();
+ done();
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/async-only-async.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/async-only-async.fixture.js
new file mode 100644
index 0000000000..d5ba2b37a0
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/async-only-async.fixture.js
@@ -0,0 +1,5 @@
+'use strict';
+
+it('should pass', function (done) {
+ done();
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/async-only-sync.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/async-only-sync.fixture.js
new file mode 100644
index 0000000000..512fd0e4db
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/async-only-sync.fixture.js
@@ -0,0 +1,3 @@
+'use strict';
+
+it('throws an error', function () {});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/bail.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/bail.fixture.js
new file mode 100644
index 0000000000..5095e63158
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/bail.fixture.js
@@ -0,0 +1,23 @@
+'use strict';
+
+describe('suite1', function () {
+ it('should display this spec', function () {});
+
+ it('should only display this error', function (done) {
+ throw new Error('this should be displayed');
+ });
+
+ it('should not display this error', function (done) {
+ throw new Error('this should not be displayed');
+ });
+});
+
+describe('suite2', function () {
+ before(function (done) {
+ throw new Error('this hook should not be displayed');
+ });
+
+ it('should not display this error', function (done) {
+ throw new Error('this should not be displayed');
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/delay-fail.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/delay-fail.fixture.js
new file mode 100644
index 0000000000..644cbc0281
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/delay-fail.fixture.js
@@ -0,0 +1,8 @@
+'use strict';
+
+setTimeout(function () {
+ throw new Error('oops');
+ /* eslint no-unreachable: off */
+ it('test', function () {});
+ run();
+}, 100);
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/delay.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/delay.fixture.js
new file mode 100644
index 0000000000..b2d49217db
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/delay.fixture.js
@@ -0,0 +1,16 @@
+'use strict';
+
+var assert = require('assert');
+var delay = 500;
+
+setTimeout(function () {
+ describe('delayed execution', function () {
+ it('should have no effect if attempted twice in the same suite', function () {
+ assert(true);
+ run();
+ assert(true);
+ });
+ });
+
+ run();
+}, delay);
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/grep.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/grep.fixture.js
new file mode 100644
index 0000000000..0939d084ec
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/grep.fixture.js
@@ -0,0 +1,19 @@
+'use strict';
+
+describe('grep', function () {
+ describe('Match', function () {
+ it('should run', function () {});
+ it('should also run', function () {});
+ });
+
+ describe('match', function () {
+ it('should run', function () {});
+ it('should also run', function () {});
+ });
+
+ describe('fail', function () {
+ it('should not be ran', function () {
+ throw new Error('Spec should not run');
+ });
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/bdd.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/bdd.fixture.js
new file mode 100644
index 0000000000..39323f3567
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/bdd.fixture.js
@@ -0,0 +1,72 @@
+'use strict';
+
+describe.only('should run this suite', function () {
+ it('should run this test', function () {});
+
+ it('should run this test', function () {});
+
+ it('should run this test', function () {});
+});
+
+describe('should not run this suite', function () {
+ it('should not run this test', function () {
+ (true).should.equal(false);
+ });
+
+ it('should not run this test', function () {
+ (true).should.equal(false);
+ });
+
+ it('should not run this test', function () {
+ (true).should.equal(false);
+ });
+});
+
+describe.only('should run this suite too', function () {
+ describe('should run this nested suite', function () {
+ it('should run this test', function () {});
+
+ it('should run this test', function () {});
+
+ it('should run this test', function () {});
+ });
+});
+
+describe.only('should run this suite, even', function () {
+ describe('should run this nested suite, even', function () {
+ describe('should run this doubly-nested suite!', function () {
+ it('should run this test', function () {});
+
+ it('should run this test', function () {});
+
+ it('should run this test', function () {});
+ });
+ });
+});
+
+describe('should run this suite with an exclusive test', function () {
+ it.only('should run this test', function () {});
+
+ describe('should not run this nested suite', function () {
+ describe.only('should not run this doubly-nested suite', function () {
+ it('should not run this test', function () {});
+
+ it('should not run this test', function () {});
+
+ it('should not run this test', function () {});
+ });
+ });
+});
+
+describe('should run this suite with an exclusive test (reverse order)', function () {
+ describe('should not run this nested suite', function () {
+ describe.only('should not run this doubly-nested suite', function () {
+ it('should not run this test', function () {});
+
+ it('should not run this test', function () {});
+
+ it('should not run this test', function () {});
+ });
+ });
+ it.only('should run this test', function () {});
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/qunit.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/qunit.fixture.js
new file mode 100644
index 0000000000..8bc598030d
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/qunit.fixture.js
@@ -0,0 +1,27 @@
+'use strict';
+
+suite.only('should run all tests in this suite');
+
+test('should run this test #1', function () {});
+
+test('should run this test #2', function () {});
+
+test('should run this test #3', function () {});
+
+test('should run this test #4', function () {});
+
+test('should run this test #5', function () {});
+
+suite('should not run any of this suite\'s tests');
+
+test('should not run this test', function () {
+ (false).should.equal(true);
+});
+
+test('should not run this test', function () {
+ (false).should.equal(true);
+});
+
+test('should not run this test', function () {
+ (false).should.equal(true);
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/tdd.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/tdd.fixture.js
new file mode 100644
index 0000000000..987ee6bfba
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/only/tdd.fixture.js
@@ -0,0 +1,37 @@
+'use strict';
+
+suite.only('should run all tests in this tdd suite', function () {
+ test('should run this test #1', function () {});
+
+ test('should run this test #2', function () {});
+
+ test('should run this test #3', function () {});
+
+ test('should run this test #4', function () {});
+});
+
+suite('should not run this suite', function () {
+ test('should not run this test', function () {
+ (true).should.equal(false);
+ });
+
+ test('should not run this test', function () {
+ (true).should.equal(false);
+ });
+
+ test('should not run this test', function () {
+ (true).should.equal(false);
+ });
+});
+
+suite.only('should run this suite too', function () {
+ suite('should run this nested suite', function () {
+ test('should run this test', function () {});
+
+ test('should run this test', function () {});
+
+ test('should run this test', function () {});
+
+ test('should run this test', function () {});
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/retries.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/retries.fixture.js
new file mode 100644
index 0000000000..8d2b0a40b6
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/retries.fixture.js
@@ -0,0 +1,7 @@
+'use strict';
+
+describe('retries', function () {
+ it('should fail', function () {
+ throw new Error('retry failure');
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/sort-alpha.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/sort-alpha.fixture.js
new file mode 100644
index 0000000000..dd74303163
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/sort-alpha.fixture.js
@@ -0,0 +1,9 @@
+'use strict';
+
+describe('alpha', function () {
+ it('should be executed first', function () {
+ if (global.beta) {
+ throw new Error('alpha was not executed first');
+ }
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/options/sort-beta.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/sort-beta.fixture.js
new file mode 100644
index 0000000000..56da4a6523
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/options/sort-beta.fixture.js
@@ -0,0 +1,7 @@
+'use strict';
+
+describe('beta', function () {
+ it('should be executed second', function () {
+ global.beta = 1;
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/passing.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/passing.fixture.js
new file mode 100644
index 0000000000..baf142026d
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/passing.fixture.js
@@ -0,0 +1,13 @@
+'use strict';
+
+var assert = require('assert');
+
+describe('suite', function () {
+ it('test1', function () {
+ assert(true);
+ });
+
+ it('test2', function () {
+ assert(true);
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-before.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-before.fixture.js
new file mode 100644
index 0000000000..efeaa93899
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-before.fixture.js
@@ -0,0 +1,18 @@
+'use strict';
+
+describe('skip in before', function () {
+ before(function (done) {
+ var self = this;
+ setTimeout(function () {
+ self.skip();
+ }, 50);
+ });
+
+ it('should never run this test', function () {
+ throw new Error('never thrown');
+ });
+
+ it('should never run this test', function () {
+ throw new Error('never thrown');
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-beforeEach.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-beforeEach.fixture.js
new file mode 100644
index 0000000000..d6225564ba
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-beforeEach.fixture.js
@@ -0,0 +1,18 @@
+'use strict';
+
+describe('skip in beforeEach', function () {
+ beforeEach(function (done) {
+ var self = this;
+ setTimeout(function () {
+ self.skip();
+ }, 50);
+ });
+
+ it('should never run this test', function () {
+ throw new Error('never thrown');
+ });
+
+ it('should never run this test', function () {
+ throw new Error('never thrown');
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-spec.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-spec.fixture.js
new file mode 100644
index 0000000000..44707b026c
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-async-spec.fixture.js
@@ -0,0 +1,14 @@
+'use strict';
+
+describe('skip in test', function () {
+ it('should skip async', function (done) {
+ var self = this;
+ setTimeout(function () {
+ self.skip();
+ }, 50);
+ });
+
+ it('should run other tests in the suite', function () {
+ // Do nothing
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-before.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-before.fixture.js
new file mode 100644
index 0000000000..5e3b208efa
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-before.fixture.js
@@ -0,0 +1,15 @@
+'use strict';
+
+describe('skip in before', function () {
+ before(function () {
+ this.skip();
+ });
+
+ it('should never run this test', function () {
+ throw new Error('never thrown');
+ });
+
+ it('should never run this test', function () {
+ throw new Error('never thrown');
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-beforeEach.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-beforeEach.fixture.js
new file mode 100644
index 0000000000..0bd155ba55
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-beforeEach.fixture.js
@@ -0,0 +1,15 @@
+'use strict';
+
+describe('skip in beforeEach', function () {
+ beforeEach(function () {
+ this.skip();
+ });
+
+ it('should never run this test', function () {
+ throw new Error('never thrown');
+ });
+
+ it('should never run this test', function () {
+ throw new Error('never thrown');
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-spec.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-spec.fixture.js
new file mode 100644
index 0000000000..1d22f0b77d
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/skip-sync-spec.fixture.js
@@ -0,0 +1,12 @@
+'use strict';
+
+describe('skip in test', function () {
+ it('should skip immediately', function () {
+ this.skip();
+ throw new Error('never thrown');
+ });
+
+ it('should run other tests in the suite', function () {
+ // Do nothing
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/spec.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/spec.fixture.js
new file mode 100644
index 0000000000..d750fcad1a
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/pending/spec.fixture.js
@@ -0,0 +1,5 @@
+'use strict';
+
+describe('suite', function () {
+ it('pending spec');
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/1794/issue-1794.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/1794/issue-1794.fixture.js
new file mode 100644
index 0000000000..8867369546
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/1794/issue-1794.fixture.js
@@ -0,0 +1,5 @@
+'use strict';
+
+test('pass', function () {
+ // pass
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/1794/simple-ui.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/1794/simple-ui.js
new file mode 100644
index 0000000000..5cfde0465f
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/1794/simple-ui.js
@@ -0,0 +1,28 @@
+'use strict';
+
+var path = '../../../../../lib/';
+var Mocha = require(path + 'mocha');
+var Test = require(path + 'test');
+
+/**
+ * A simple UI that only exposes a single function: test
+ */
+module.exports = Mocha.interfaces['simple-ui'] = function (suite) {
+ suite.on('pre-require', function (context, file, mocha) {
+ var common = require(path + 'interfaces/common')([suite], context);
+
+ context.run = mocha.options.delay && common.runWithSuite(suite);
+
+ /**
+ * Describes a specification or test-case with the given `title`
+ * and callback `fn` acting as a thunk.
+ */
+ context.test = function (title, fn) {
+ var test = new Test(title, fn);
+ test.file = file;
+ suite.addTest(test);
+
+ return test;
+ };
+ });
+};
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1327.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1327.fixture.js
new file mode 100644
index 0000000000..e788278d6d
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1327.fixture.js
@@ -0,0 +1,17 @@
+'use strict';
+
+it('test 1', function () {
+ console.log('testbody1');
+ process.nextTick(function () {
+ throw new Error('Too bad');
+ });
+});
+
+it('test 2', function () {
+ console.log('testbody2');
+});
+
+it('test 3', function () {
+ console.log('testbody3');
+ throw new Error('OUCH');
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1417.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1417.js
new file mode 100644
index 0000000000..13ce053784
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1417.js
@@ -0,0 +1,22 @@
+'use strict';
+
+/**
+ * This file should generate only one failure per spec for the thrown error.
+ * It should not report misleading 'multiple calls to done()'.
+ */
+
+it('fails exactly once when a global error is thrown synchronously and done errors', function (done) {
+ setTimeout(function () {
+ done(new Error('test error'));
+ }, 1); // Not 0 - it will 'succeed', but won't test the breaking condition
+
+ throw new Error('sync error');
+});
+
+it('fails exactly once when a global error is thrown synchronously and done completes', function (done) {
+ setTimeout(function () {
+ done();
+ }, 1); // Not 0 - it will 'succeed', but won't test the breaking condition
+
+ throw new Error('sync error');
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1991.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1991.fixture.js
new file mode 100644
index 0000000000..024f02519f
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-1991.fixture.js
@@ -0,0 +1,49 @@
+'use strict';
+
+/* eslint no-unused-vars: off */
+
+function MemoryLeak () {
+ this.myArr = [];
+ for (var i = 0; i < 1000000; i++) {
+ this.myArr.push(i);
+ }
+}
+
+var numOfTests = 300;
+for (var i = 0; i < numOfTests; i += 1) {
+ /*
+ * This Test suite will crash V8 due to:
+ * 'FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory'
+ * if all the deferred functions references have not been cleared
+ */
+ describe('Memory Leak Suite #' + i, function () {
+ // The <closureVar> variable will be accessed by the test below.
+ // As long as those test's functions are
+ // referenced in memory, the closure variable may not be garbage collected
+ // as it is still referenced.
+ // * In a chrome heap snapshot it will appear under "system / Context" (a scope)
+ var closureVar;
+
+ before(function () {
+ var x = closureVar ? 1 : 2;
+ });
+
+ after(function () {
+ var x = closureVar[0];
+ });
+
+ beforeEach(function () {
+ var x = closureVar ? 1 : 2;
+ });
+
+ afterEach(function () {
+ var x = closureVar[0];
+ });
+
+ it('access a variable via a closure', function () {
+ // slow performance on older node.js versions
+ this.timeout(1000);
+ closureVar = new MemoryLeak();
+ });
+ });
+}
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2315.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2315.js
new file mode 100644
index 0000000000..fe18841d1c
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2315.js
@@ -0,0 +1,11 @@
+'use strict';
+
+describe('issue-2315: cannot read property currentRetry of undefined', function () {
+ before(function () {
+ process.nextTick(function () {
+ throw new Error();
+ });
+ });
+
+ it('something', function () {});
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2406.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2406.fixture.js
new file mode 100644
index 0000000000..b3770014dd
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2406.fixture.js
@@ -0,0 +1,17 @@
+'use strict';
+
+describe('outer describe', function () {
+ it('should not run this test', function () {});
+ describe('this suite should not run', function () {
+ it('should not run this test', function () {});
+ });
+ describe.only('this .only suite should run', function () {
+ describe('this suite should run', function () {
+ it('should run this test in a nested suite', function () {});
+ });
+ it('should run this test', function () {});
+ });
+ describe('this suite should not run', function () {
+ it('should not run this test', function () {});
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2417.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2417.fixture.js
new file mode 100644
index 0000000000..58f49cf846
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/regression/issue-2417.fixture.js
@@ -0,0 +1,9 @@
+'use strict';
+
+describe('outer describe', function () {
+ describe.only('outer describe.only', function () {
+ it.only('inner it.only', function () {
+ // should run and exit without error
+ });
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/async.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/async.fixture.js
new file mode 100644
index 0000000000..56d067fc05
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/async.fixture.js
@@ -0,0 +1,30 @@
+'use strict';
+
+describe('retries', function () {
+ var times = 0;
+ before(function () {
+ console.log('before');
+ });
+
+ after(function () {
+ console.log('after');
+ });
+
+ beforeEach(function () {
+ console.log('before each', times);
+ });
+
+ afterEach(function () {
+ console.log('after each', times);
+ });
+
+ it('should allow override and run appropriate hooks', function (done) {
+ this.timeout(200);
+ this.retries(2);
+ console.log('TEST', times);
+ if (++times < 3) {
+ return setTimeout(done, 300);
+ }
+ setTimeout(done, 50);
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/early-pass.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/early-pass.fixture.js
new file mode 100644
index 0000000000..ddad40399e
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/early-pass.fixture.js
@@ -0,0 +1,13 @@
+'use strict';
+
+describe('retries', function () {
+ this.retries(1);
+ var times = 0;
+
+ it('should pass after 1 retry', function () {
+ times++;
+ if (times !== 2) {
+ throw new Error('retry error ' + times);
+ }
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/hooks.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/hooks.fixture.js
new file mode 100644
index 0000000000..b4fc081aaa
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/hooks.fixture.js
@@ -0,0 +1,27 @@
+'use strict';
+
+describe('retries', function () {
+ var times = 0;
+ before(function () {
+ console.log('before');
+ });
+
+ after(function () {
+ console.log('after');
+ });
+
+ beforeEach(function () {
+ console.log('before each', times);
+ });
+
+ afterEach(function () {
+ console.log('after each', times);
+ });
+
+ it('should allow override and run appropriate hooks', function () {
+ this.retries(4);
+ console.log('TEST', times);
+ times++;
+ throw new Error('retry error');
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/nested.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/nested.fixture.js
new file mode 100644
index 0000000000..877d519d7f
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/retries/nested.fixture.js
@@ -0,0 +1,11 @@
+'use strict';
+
+describe('retries', function () {
+ this.retries(3);
+ describe('nested', function () {
+ it('should fail after only 1 retry', function () {
+ this.retries(1);
+ throw new Error('retry error');
+ });
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-no-callback.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-no-callback.fixture.js
new file mode 100644
index 0000000000..80d046438f
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-no-callback.fixture.js
@@ -0,0 +1,3 @@
+'use strict';
+
+describe('a suite without a callback');
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-skipped-callback.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-skipped-callback.fixture.js
new file mode 100644
index 0000000000..6def25de7f
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-skipped-callback.fixture.js
@@ -0,0 +1,3 @@
+'use strict';
+
+xdescribe('a pending suite with a callback', function () {});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-skipped-no-callback.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-skipped-no-callback.fixture.js
new file mode 100644
index 0000000000..e9381159bf
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/suite/suite-skipped-no-callback.fixture.js
@@ -0,0 +1,3 @@
+'use strict';
+
+xdescribe('a pending suite without a callback');
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/timeout.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/timeout.fixture.js
new file mode 100644
index 0000000000..d237436811
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/timeout.fixture.js
@@ -0,0 +1,19 @@
+'use strict';
+
+describe('timeout', function () {
+ this.timeout(1);
+
+ it('should be honored with sync suites', function () {
+ sleep(2);
+ });
+
+ it('should be honored with async suites', function (done) {
+ sleep(2);
+ done();
+ });
+
+ function sleep (ms) {
+ var start = Date.now();
+ while (start + ms > Date.now());
+ }
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/uncaught-hook.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/uncaught-hook.fixture.js
new file mode 100644
index 0000000000..54f30c56e9
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/uncaught-hook.fixture.js
@@ -0,0 +1,15 @@
+'use strict';
+
+describe('uncaught', function () {
+ beforeEach(function (done) {
+ process.nextTick(function () {
+ throw new Error('oh noes');
+ });
+ });
+
+ it('test', function (done) {
+ process.nextTick(function () {
+ throw new Error("I'm uncaught!");
+ });
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/fixtures/uncaught.fixture.js b/tests/lib/mocha-3.1.2/test/integration/fixtures/uncaught.fixture.js
new file mode 100644
index 0000000000..6a2ded880c
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/fixtures/uncaught.fixture.js
@@ -0,0 +1,22 @@
+'use strict';
+
+/**
+ * This file should only generate one failure per spec despite the fact that
+ * Mocha is capable of detecting two distinct exceptions during test execution.
+ */
+
+it('fails exactly once when a global error is thrown first', function (done) {
+ setTimeout(function () {
+ throw new Error('global error');
+ }, 0);
+});
+
+it('fails exactly once when a global error is thrown second', function (done) {
+ setTimeout(function () {
+ done(new Error('test error'));
+ }, 0);
+
+ setTimeout(function () {
+ throw new Error('global error');
+ }, 0);
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/helpers.js b/tests/lib/mocha-3.1.2/test/integration/helpers.js
new file mode 100644
index 0000000000..7f6a608a6f
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/helpers.js
@@ -0,0 +1,193 @@
+'use strict';
+
+var spawn = require('child_process').spawn;
+var path = require('path');
+var fs = require('fs');
+var baseReporter = require('../../lib/reporters/base');
+
+module.exports = {
+ /**
+ * Invokes the mocha binary for the given fixture with color output disabled.
+ * Accepts an array of additional command line args to pass. The callback is
+ * invoked with a summary of the run, in addition to its output. The summary
+ * includes the number of passing, pending, and failing tests, as well as the
+ * exit code. Useful for testing different reporters.
+ *
+ * Example response:
+ * {
+ * pending: 0,
+ * passing: 0,
+ * failing: 1,
+ * code: 1,
+ * output: '...'
+ * }
+ *
+ * @param {string} fixturePath
+ * @param {array} args
+ * @param {function} fn
+ */
+ runMocha: function (fixturePath, args, fn) {
+ var path;
+
+ path = resolveFixturePath(fixturePath);
+ args = args || [];
+
+ invokeMocha(args.concat(['-C', path]), function (err, res) {
+ if (err) return fn(err);
+
+ fn(null, getSummary(res));
+ });
+ },
+
+ /**
+ * Invokes the mocha binary on the code of the body of the function.
+ * Accepts an array of additional command line args to pass. The callback is
+ * invoked with a summary of the run, in addition to its output. The summary
+ * includes the number of passing, pending, and failing tests, as well as the
+ * exit code. Useful for testing different reporters.
+ *
+ * Example response:
+ * {
+ * pending: 0,
+ * passing: 0,
+ * failing: 1,
+ * code: 1,
+ * output: '...'
+ * }
+ *
+ * @param {function} fixture
+ * @param {array} args
+ * @param {function} fn
+ */
+ runMochaFunction: function (fixture, args, fn) {
+ var path = resolveFixturePath(fixture.name + '.js' || 'tempfile.js');
+ args = args || [];
+
+ var fixtureContent = 'var fn = ' + fixture.toString() + '; fn()';
+ fs.writeFileSync(path, fixtureContent, 'utf8');
+
+ function cleanup () {
+ fs.unlink(path);
+ fn.apply(this, arguments);
+ }
+
+ invokeMocha(args.concat(['-C', path]), function (err, res) {
+ if (err) {
+ return cleanup(err);
+ }
+
+ cleanup(null, getSummary(res));
+ });
+ },
+
+ /**
+ * Invokes the mocha binary for the given fixture using the JSON reporter,
+ * returning the parsed output, as well as exit code.
+ *
+ * @param {string} fixturePath
+ * @param {array} args
+ * @param {function} fn
+ */
+ runMochaJSON: function (fixturePath, args, fn) {
+ var path;
+
+ path = resolveFixturePath(fixturePath);
+ args = args || [];
+
+ invokeMocha(args.concat(['--reporter', 'json', path]), function (err, res) {
+ if (err) return fn(err);
+
+ try {
+ var result = JSON.parse(res.output);
+ result.code = res.code;
+ } catch (err) {
+ return fn(err);
+ }
+
+ fn(null, result);
+ });
+ },
+
+ /**
+ * Returns an array of diffs corresponding to exceptions thrown from specs,
+ * given the plaintext output (-C) of a mocha run.
+ *
+ * @param {string} output
+ * returns {string[]}
+ */
+ getDiffs: function (output) {
+ var diffs, i, inDiff, inStackTrace;
+
+ diffs = [];
+ output.split('\n').forEach(function (line) {
+ if (line.match(/^\s{2}\d+\)/)) {
+ // New spec, e.g. "1) spec title"
+ diffs.push([]);
+ i = diffs.length - 1;
+ inStackTrace = false;
+ inDiff = false;
+ } else if (!diffs.length || inStackTrace) {
+ // Haven't encountered a spec yet
+ // or we're in the middle of a stack trace
+ return;
+ } else if (line.indexOf('+ expected - actual') !== -1) {
+ inDiff = true;
+ } else if (line.match(/at Context/)) {
+ // At the start of a stack trace
+ inStackTrace = true;
+ inDiff = false;
+ } else if (inDiff) {
+ diffs[i].push(line);
+ }
+ });
+
+ // Ignore empty lines before/after diff
+ return diffs.map(function (diff) {
+ return diff.slice(1, -3).join('\n');
+ });
+ },
+
+ /**
+ * regular expression used for splitting lines based on new line / dot symbol.
+ */
+ splitRegExp: new RegExp('[\\n' + baseReporter.symbols.dot + ']+')
+};
+
+function invokeMocha (args, fn) {
+ var output, mocha, listener;
+
+ output = '';
+ args = [path.join('bin', 'mocha')].concat(args);
+ mocha = spawn(process.execPath, args);
+
+ listener = function (data) {
+ output += data;
+ };
+
+ mocha.stdout.on('data', listener);
+ mocha.stderr.on('data', listener);
+ mocha.on('error', fn);
+
+ mocha.on('close', function (code) {
+ fn(null, {
+ output: output.split('\n').join('\n'),
+ code: code
+ });
+ });
+}
+
+function resolveFixturePath (fixture) {
+ return path.join('./test/integration/fixtures', fixture);
+}
+
+function getSummary (res) {
+ return ['passing', 'pending', 'failing'].reduce(function (summary, type) {
+ var pattern, match;
+
+ pattern = new RegExp(' (\\d+) ' + type + '\\s');
+ match = pattern.exec(res.output);
+ summary[type] = (match) ? parseInt(match, 10) : 0;
+
+ return summary;
+ }, res);
+}
diff --git a/tests/lib/mocha-3.1.2/test/integration/hook-err.spec.js b/tests/lib/mocha-3.1.2/test/integration/hook-err.spec.js
new file mode 100644
index 0000000000..fbdd7e8e38
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/hook-err.spec.js
@@ -0,0 +1,217 @@
+'use strict';
+
+var assert = require('assert');
+var runMocha = require('./helpers').runMocha;
+var splitRegExp = require('./helpers').splitRegExp;
+var bang = require('../../lib/reporters/base').symbols.bang;
+
+describe('hook error handling', function () {
+ var lines;
+
+ describe('before hook error', function () {
+ before(run('hooks/before-hook-error.fixture.js'));
+ it('should verify results', function () {
+ assert.deepEqual(
+ lines,
+ ['before', bang + 'test 3']
+ );
+ });
+ });
+
+ describe('before hook error tip', function () {
+ before(run('hooks/before-hook-error-tip.fixture.js', onlyErrorTitle));
+ it('should verify results', function () {
+ assert.deepEqual(
+ lines,
+ ['1) spec 2 "before all" hook:']
+ );
+ });
+ });
+
+ describe('before each hook error', function () {
+ before(run('hooks/beforeEach-hook-error.fixture.js'));
+ it('should verify results', function () {
+ assert.deepEqual(
+ lines,
+ ['before', bang + 'test 3']
+ );
+ });
+ });
+
+ describe('after hook error', function () {
+ before(run('hooks/after-hook-error.fixture.js'));
+ it('should verify results', function () {
+ assert.deepEqual(
+ lines,
+ ['test 1', 'test 2', 'after', bang + 'test 3']
+ );
+ });
+ });
+
+ describe('after each hook error', function () {
+ before(run('hooks/afterEach-hook-error.fixture.js'));
+ it('should verify results', function () {
+ assert.deepEqual(
+ lines,
+ ['test 1', 'after', bang + 'test 3']
+ );
+ });
+ });
+
+ describe('multiple hook errors', function () {
+ before(run('hooks/multiple-hook-error.fixture.js'));
+ it('should verify results', function () {
+ assert.deepEqual(
+ lines,
+ [
+ 'root before',
+ '1-1 before',
+ 'root before each',
+ '1 before each',
+ '1-1 before each',
+ bang + '1-1 after each',
+ '1 after each',
+ 'root after each',
+ '1-1 after',
+ bang + '1-2 before',
+ 'root before each',
+ '1 before each',
+ '1-2 before each',
+ '1-2 test 1',
+ '1-2 after each',
+ bang + '1 after each',
+ 'root after each',
+ '1-2 after',
+ '1 after',
+ '2-1 before',
+ 'root before each',
+ '2 before each',
+ bang + '2 after each',
+ bang + 'root after each',
+ '2-1 after',
+ '2 after',
+ 'root after'
+ ]
+ );
+ });
+ });
+
+ describe('async - before hook error', function () {
+ before(run('hooks/before-hook-async-error.fixture.js'));
+ it('should verify results', function () {
+ assert.deepEqual(
+ lines,
+ ['before', bang + 'test 3']
+ );
+ });
+ });
+
+ describe('async - before hook error tip', function () {
+ before(run('hooks/before-hook-async-error-tip.fixture.js', onlyErrorTitle));
+ it('should verify results', function () {
+ assert.deepEqual(
+ lines,
+ ['1) spec 2 "before all" hook:']
+ );
+ });
+ });
+
+ describe('async - before each hook error', function () {
+ before(run('hooks/beforeEach-hook-async-error.fixture.js'));
+ it('should verify results', function () {
+ assert.deepEqual(
+ lines,
+ ['before', bang + 'test 3']
+ );
+ });
+ });
+
+ describe('async - after hook error', function () {
+ before(run('hooks/after-hook-async-error.fixture.js'));
+ it('should verify results', function () {
+ assert.deepEqual(
+ lines,
+ ['test 1', 'test 2', 'after', bang + 'test 3']
+ );
+ });
+ });
+
+ describe('async - after each hook error', function () {
+ before(run('hooks/afterEach-hook-async-error.fixture.js'));
+ it('should verify results', function () {
+ assert.deepEqual(
+ lines,
+ ['test 1', 'after', bang + 'test 3']
+ );
+ });
+ });
+
+ describe('async - multiple hook errors', function () {
+ before(run('hooks/multiple-hook-async-error.fixture.js'));
+ it('should verify results', function () {
+ assert.deepEqual(
+ lines,
+ [
+ 'root before',
+ '1-1 before',
+ 'root before each',
+ '1 before each',
+ '1-1 before each',
+ bang + '1-1 after each',
+ '1 after each',
+ 'root after each',
+ '1-1 after',
+ bang + '1-2 before',
+ 'root before each',
+ '1 before each',
+ '1-2 before each',
+ '1-2 test 1',
+ '1-2 after each',
+ bang + '1 after each',
+ 'root after each',
+ '1-2 after',
+ '1 after',
+ '2-1 before',
+ 'root before each',
+ '2 before each',
+ bang + '2 after each',
+ bang + 'root after each',
+ '2-1 after',
+ '2 after',
+ 'root after'
+ ]
+ );
+ });
+ });
+
+ function run (fnPath, outputFilter) {
+ return function (done) {
+ runMocha(fnPath, [], function (err, res) {
+ assert.ifError(err);
+
+ lines = res.output
+ .split(splitRegExp)
+ .map(function (line) {
+ return line.trim();
+ })
+ .filter(outputFilter || onlyConsoleOutput());
+
+ done();
+ });
+ };
+ }
+});
+
+function onlyConsoleOutput () {
+ var foundSummary = false;
+ return function (line) {
+ if (!foundSummary) {
+ foundSummary = !!(/\(\d+ms\)/).exec(line);
+ }
+ return !foundSummary && line.length > 0;
+ };
+}
+
+function onlyErrorTitle (line) {
+ return !!(/^1\)/).exec(line);
+}
diff --git a/tests/lib/mocha-3.1.2/test/integration/hooks.spec.js b/tests/lib/mocha-3.1.2/test/integration/hooks.spec.js
new file mode 100644
index 0000000000..0d31cbfdf4
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/hooks.spec.js
@@ -0,0 +1,45 @@
+'use strict';
+
+var assert = require('assert');
+var run = require('./helpers').runMocha;
+var splitRegExp = require('./helpers').splitRegExp;
+var args = [];
+
+describe('hooks', function () {
+ it('are ran in correct order', function (done) {
+ run('cascade.fixture.js', args, function (err, res) {
+ var lines, expected;
+
+ assert(!err);
+
+ lines = res.output.split(splitRegExp).map(function (line) {
+ return line.trim();
+ }).filter(function (line) {
+ return line.length;
+ }).slice(0, -1);
+
+ expected = [
+ 'before one',
+ 'before two',
+ 'before three',
+ 'before each one',
+ 'before each two',
+ 'before each three',
+ 'TEST three',
+ 'after each three',
+ 'after each two',
+ 'after each one',
+ 'after three',
+ 'after two',
+ 'after one'
+ ];
+
+ expected.forEach(function (line, i) {
+ assert.equal(lines[i], line);
+ });
+
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/multiple-done.spec.js b/tests/lib/mocha-3.1.2/test/integration/multiple-done.spec.js
new file mode 100644
index 0000000000..76a6483115
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/multiple-done.spec.js
@@ -0,0 +1,98 @@
+'use strict';
+
+var assert = require('assert');
+var run = require('./helpers').runMochaJSON;
+var args = [];
+
+describe('multiple calls to done()', function () {
+ var res;
+ describe('from a spec', function () {
+ before(function (done) {
+ run('multiple-done.fixture.js', args, function (err, result) {
+ res = result;
+ done(err);
+ });
+ });
+
+ it('results in failures', function () {
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 1);
+ assert.equal(res.stats.failures, 1);
+ assert.equal(res.code, 1);
+ });
+
+ it('throws a descriptive error', function () {
+ assert.equal(res.failures[0].err.message,
+ 'done() called multiple times');
+ });
+ });
+
+ describe('with multiple specs', function () {
+ before(function (done) {
+ run('multiple-done-specs.fixture.js', args, function (err, result) {
+ res = result;
+ done(err);
+ });
+ });
+
+ it('results in a failure', function () {
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 2);
+ assert.equal(res.stats.failures, 1);
+ assert.equal(res.code, 1);
+ });
+
+ it('correctly attributes the error', function () {
+ assert.equal(res.failures[0].fullTitle, 'suite test1');
+ assert.equal(res.failures[0].err.message,
+ 'done() called multiple times');
+ });
+ });
+
+ describe('from a before hook', function () {
+ before(function (done) {
+ run('multiple-done-before.fixture.js', args, function (err, result) {
+ res = result;
+ done(err);
+ });
+ });
+
+ it('results in a failure', function () {
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 1);
+ assert.equal(res.stats.failures, 1);
+ assert.equal(res.code, 1);
+ });
+
+ it('correctly attributes the error', function () {
+ assert.equal(res.failures[0].fullTitle, 'suite "before all" hook');
+ assert.equal(res.failures[0].err.message,
+ 'done() called multiple times');
+ });
+ });
+
+ describe('from a beforeEach hook', function () {
+ before(function (done) {
+ run('multiple-done-beforeEach.fixture.js', args, function (err, result) {
+ res = result;
+ done(err);
+ });
+ });
+
+ it('results in a failure', function () {
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 2);
+ assert.equal(res.stats.failures, 2);
+ assert.equal(res.code, 2);
+ });
+
+ it('correctly attributes the errors', function () {
+ assert.equal(res.failures.length, 2);
+ res.failures.forEach(function (failure) {
+ assert.equal(failure.fullTitle, 'suite "before each" hook');
+ assert.equal(failure.err.message,
+ 'done() called multiple times');
+ });
+ });
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/only.spec.js b/tests/lib/mocha-3.1.2/test/integration/only.spec.js
new file mode 100644
index 0000000000..b37a4b263e
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/only.spec.js
@@ -0,0 +1,45 @@
+'use strict';
+
+var run = require('./helpers').runMochaJSON;
+var assert = require('assert');
+
+describe('.only()', function () {
+ describe('bdd', function () {
+ it('should run only tests that marked as `only`', function (done) {
+ run('options/only/bdd.fixture.js', ['--ui', 'bdd'], function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 11);
+ assert.equal(res.stats.failures, 0);
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+ });
+
+ describe('tdd', function () {
+ it('should run only tests that marked as `only`', function (done) {
+ run('options/only/tdd.fixture.js', ['--ui', 'tdd'], function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 8);
+ assert.equal(res.stats.failures, 0);
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+ });
+
+ describe('qunit', function () {
+ it('should run only tests that marked as `only`', function (done) {
+ run('options/only/qunit.fixture.js', ['--ui', 'qunit'], function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 5);
+ assert.equal(res.stats.failures, 0);
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/options.spec.js b/tests/lib/mocha-3.1.2/test/integration/options.spec.js
new file mode 100644
index 0000000000..7c7a3cc75e
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/options.spec.js
@@ -0,0 +1,183 @@
+'use strict';
+
+var assert = require('assert');
+var run = require('./helpers').runMochaJSON;
+var args = [];
+
+describe('options', function () {
+ describe('--async-only', function () {
+ before(function () {
+ args = ['--async-only'];
+ });
+
+ it('should fail synchronous specs', function (done) {
+ run('options/async-only-sync.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 0);
+ assert.equal(res.stats.failures, 1);
+
+ assert.equal(res.failures[0].title, 'throws an error');
+ assert.equal(res.code, 1);
+ done();
+ });
+ });
+
+ it('should allow asynchronous specs', function (done) {
+ run('options/async-only-async.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 1);
+ assert.equal(res.stats.failures, 0);
+
+ assert.equal(res.passes[0].title, 'should pass');
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+ });
+
+ describe('--bail', function () {
+ before(function () {
+ args = ['--bail'];
+ });
+
+ it('should stop after the first error', function (done) {
+ run('options/bail.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 1);
+ assert.equal(res.stats.failures, 1);
+
+ assert.equal(res.passes[0].title, 'should display this spec');
+ assert.equal(res.failures[0].title, 'should only display this error');
+ assert.equal(res.code, 1);
+ done();
+ });
+ });
+ });
+
+ describe('--sort', function () {
+ before(function () {
+ args = ['--sort'];
+ });
+
+ it('should sort tests in alphabetical order', function (done) {
+ run('options/sort*', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 2);
+ assert.equal(res.stats.failures, 0);
+
+ assert.equal(res.passes[0].fullTitle,
+ 'alpha should be executed first');
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+ });
+
+ describe('--delay', function () {
+ before(function () {
+ args = ['--delay'];
+ });
+
+ it('should run the generated test suite', function (done) {
+ run('options/delay.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 1);
+ assert.equal(res.stats.failures, 0);
+
+ assert.equal(res.passes[0].title,
+ 'should have no effect if attempted twice in the same suite');
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+
+ it('should throw an error if the test suite failed to run', function (done) {
+ run('options/delay-fail.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 0);
+ assert.equal(res.stats.failures, 1);
+
+ assert.equal(res.failures[0].title,
+ 'Uncaught error outside test suite');
+ assert.equal(res.code, 1);
+ done();
+ });
+ });
+ });
+
+ describe('--grep', function () {
+ it('runs specs matching a string', function (done) {
+ args = ['--grep', 'match'];
+ run('options/grep.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 2);
+ assert.equal(res.stats.failures, 0);
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+
+ describe('runs specs matching a RegExp', function () {
+ it('with RegExp like strings(pattern follow by flag)', function (done) {
+ args = ['--grep', '/match/i'];
+ run('options/grep.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 4);
+ assert.equal(res.stats.failures, 0);
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+
+ it('string as pattern', function (done) {
+ args = ['--grep', '.*'];
+ run('options/grep.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 4);
+ assert.equal(res.stats.failures, 1);
+ assert.equal(res.code, 1);
+ done();
+ });
+ });
+ });
+
+ describe('with --invert', function () {
+ it('runs specs that do not match the pattern', function (done) {
+ args = ['--grep', 'fail', '--invert'];
+ run('options/grep.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 4);
+ assert.equal(res.stats.failures, 0);
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+ });
+ });
+
+ describe('--retries', function () {
+ it('retries after a certain threshold', function (done) {
+ args = ['--retries', '3'];
+ run('options/retries.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 0);
+ assert.equal(res.stats.tests, 1);
+ assert.equal(res.tests[0].currentRetry, 3);
+ assert.equal(res.stats.failures, 1);
+ assert.equal(res.code, 1);
+ done();
+ });
+ });
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/pending.spec.js b/tests/lib/mocha-3.1.2/test/integration/pending.spec.js
new file mode 100644
index 0000000000..19ae30ad3a
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/pending.spec.js
@@ -0,0 +1,102 @@
+'use strict';
+
+var assert = require('assert');
+var run = require('./helpers').runMochaJSON;
+var args = [];
+
+describe('pending', function () {
+ describe('pending specs', function () {
+ it('should be created by omitting a function', function (done) {
+ run('pending/spec.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 1);
+ assert.equal(res.stats.passes, 0);
+ assert.equal(res.stats.failures, 0);
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+ });
+
+ describe('synchronous skip()', function () {
+ describe('in spec', function () {
+ it('should immediately skip the spec and run all others', function (done) {
+ run('pending/skip-sync-spec.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 1);
+ assert.equal(res.stats.passes, 1);
+ assert.equal(res.stats.failures, 0);
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+ });
+
+ describe('in before', function () {
+ it('should skip all suite specs', function (done) {
+ run('pending/skip-sync-before.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 2);
+ assert.equal(res.stats.passes, 0);
+ assert.equal(res.stats.failures, 0);
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+ });
+
+ describe('in beforeEach', function () {
+ it('should skip all suite specs', function (done) {
+ run('pending/skip-sync-beforeEach.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 2);
+ assert.equal(res.stats.passes, 0);
+ assert.equal(res.stats.failures, 0);
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+ });
+ });
+
+ describe('asynchronous skip()', function () {
+ describe('in spec', function () {
+ it('should immediately skip the spec and run all others', function (done) {
+ run('pending/skip-async-spec.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 1);
+ assert.equal(res.stats.passes, 1);
+ assert.equal(res.stats.failures, 0);
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+ });
+
+ describe('in before', function () {
+ it('should skip all suite specs', function (done) {
+ run('pending/skip-async-before.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 2);
+ assert.equal(res.stats.passes, 0);
+ assert.equal(res.stats.failures, 0);
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+ });
+
+ describe('in beforeEach', function () {
+ it('should skip all suite specs', function (done) {
+ run('pending/skip-sync-beforeEach.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 2);
+ assert.equal(res.stats.passes, 0);
+ assert.equal(res.stats.failures, 0);
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+ });
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/regression.spec.js b/tests/lib/mocha-3.1.2/test/integration/regression.spec.js
new file mode 100644
index 0000000000..ffd17aa979
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/regression.spec.js
@@ -0,0 +1,119 @@
+'use strict';
+
+var assert = require('assert');
+var fs = require('fs');
+var path = require('path');
+var run = require('./helpers').runMocha;
+var runJSON = require('./helpers').runMochaJSON;
+
+describe('regressions', function () {
+ it('issue-1327: should run all 3 specs exactly once', function (done) {
+ var args = [];
+ run('regression/issue-1327.fixture.js', args, function (err, res) {
+ var occurences = function (str) {
+ var pattern = new RegExp(str, 'g');
+ return (res.output.match(pattern) || []).length;
+ };
+
+ assert(!err);
+ assert.equal(occurences('testbody1'), 1);
+ assert.equal(occurences('testbody2'), 1);
+ assert.equal(occurences('testbody3'), 1);
+
+ assert.equal(res.code, 1);
+ done();
+ });
+ });
+
+ it('should not duplicate mocha.opts args in process.argv', function () {
+ var processArgv = process.argv.join('');
+ var mochaOpts = fs.readFileSync(path.join(__dirname, '..', 'mocha.opts'), 'utf-8').split(/[\s]+/).join('');
+ assert.notEqual(processArgv.indexOf(mochaOpts), -1, 'process.argv missing mocha.opts');
+ assert.equal(processArgv.indexOf(mochaOpts), processArgv.lastIndexOf(mochaOpts), 'process.argv contains duplicated mocha.opts');
+ });
+
+ it('issue-1794: Can\'t --require custom UI and use it', function (done) {
+ var simpleUiPath = path.join(__dirname, 'fixtures', 'regression', '1794', 'simple-ui.js');
+ var args = ['--require', simpleUiPath, '--ui', 'simple-ui'];
+ run('regression/1794/issue-1794.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.code, 0, 'Custom UI should be loaded');
+ done();
+ });
+ });
+
+ it('issue-1991: Declarations do not get cleaned up unless you set them to `null` - Memory Leak', function (done) {
+ // on a modern MBP takes ±5 seconds on node 4.0, but on older laptops with node 0.12 ±40 seconds.
+ // Could easily take longer on even weaker machines (Travis-CI containers for example).
+ this.timeout(120000);
+ run('regression/issue-1991.fixture.js', [], function (err, res) {
+ assert(!err);
+ assert.equal(/process out of memory/.test(res.output), false, 'fixture\'s process out of memory!');
+ assert.equal(res.code, 0, 'Runnable fn (it/before[Each]/after[Each]) references should be deleted to avoid memory leaks');
+ done();
+ });
+ });
+
+ describe('issue-2286: after doesn\'t execute if test was skipped in beforeEach', function () {
+ var afterWasRun = false;
+ describe('suite with skipped test for meta test', function () {
+ beforeEach(function () { this.skip(); });
+ after(function () { afterWasRun = true; });
+ it('should be pending', function () {});
+ });
+ after('meta test', function () {
+ afterWasRun.should.be.ok();
+ });
+ });
+
+ it('issue-2315: cannot read property currentRetry of undefined', function (done) {
+ runJSON('regression/issue-2315.js', [], function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 0);
+ assert.equal(res.stats.failures, 1);
+ assert.equal(res.code, 1);
+ done();
+ });
+ });
+
+ it('issue-2406: should run nested describe.only suites', function (done) {
+ this.timeout(2000);
+ runJSON('regression/issue-2406.fixture.js', [], function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 2);
+ assert.equal(res.stats.failures, 0);
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+
+ it('issue-2417: should not recurse infinitely with .only suites nested within each other', function () {
+ runJSON('regression/issue-2417.fixture.js', [], function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 1);
+ assert.equal(res.stats.failures, 0);
+ assert.equal(res.code, 0);
+ });
+ });
+
+ it('issue-1417 uncaught exceptions from async specs', function (done) {
+ runJSON('regression/issue-1417.js', [], function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 0);
+ assert.equal(res.stats.failures, 2);
+
+ assert.equal(res.failures[0].title,
+ 'fails exactly once when a global error is thrown synchronously and done errors');
+ assert.equal(res.failures[0].err.message, 'sync error');
+ assert.equal(res.failures[1].title,
+ 'fails exactly once when a global error is thrown synchronously and done completes');
+ assert.equal(res.failures[1].err.message, 'sync error');
+ assert.equal(res.code, 2);
+ done();
+ });
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/reporters.spec.js b/tests/lib/mocha-3.1.2/test/integration/reporters.spec.js
new file mode 100644
index 0000000000..5cfee57037
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/reporters.spec.js
@@ -0,0 +1,63 @@
+'use strict';
+
+var assert = require('assert');
+var os = require('os');
+var fs = require('fs');
+var crypto = require('crypto');
+var path = require('path');
+var run = require('./helpers').runMocha;
+
+describe('reporters', function () {
+ describe('markdown', function () {
+ var res;
+
+ before(function (done) {
+ run('passing.fixture.js', ['--reporter', 'markdown'], function (err, result) {
+ res = result;
+ done(err);
+ });
+ });
+
+ it('does not exceed maximum callstack (issue: 1875)', function () {
+ assert(res.output.indexOf('RangeError') === -1, 'Threw RangeError');
+ });
+
+ it('contains spec src', function () {
+ var src = [
+ '```js',
+ 'assert(true);',
+ '```'
+ ].join('\n');
+
+ assert(res.output.indexOf(src) !== -1, 'No assert found');
+ });
+ });
+
+ describe('xunit', function () {
+ it('prints test cases with --reporter-options output (issue: 1864)', function (done) {
+ var randomStr = crypto.randomBytes(8).toString('hex');
+ var tmpDir = os.tmpDir().replace(new RegExp(path.sep + '$'), '');
+ var tmpFile = tmpDir + path.sep + 'test-issue-1864-' + randomStr + '.xml';
+
+ var args = ['--reporter=xunit', '--reporter-options', 'output=' + tmpFile];
+ var expectedOutput = [
+ '<testcase classname="suite" name="test1" time="',
+ '<testcase classname="suite" name="test2" time="',
+ '</testsuite>'
+ ];
+
+ run('passing.fixture.js', args, function (err, result) {
+ if (err) return done(err);
+
+ var xml = fs.readFileSync(tmpFile, 'utf8');
+ fs.unlinkSync(tmpFile);
+
+ expectedOutput.forEach(function (line) {
+ assert(xml.indexOf(line) !== -1, 'XML did not contain ' + line);
+ });
+
+ done(err);
+ });
+ });
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/retries.spec.js b/tests/lib/mocha-3.1.2/test/integration/retries.spec.js
new file mode 100644
index 0000000000..28ed702c5f
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/retries.spec.js
@@ -0,0 +1,108 @@
+'use strict';
+
+var assert = require('assert');
+var helpers = require('./helpers');
+var args = [];
+var bang = require('../../lib/reporters/base').symbols.bang;
+
+describe('retries', function () {
+ it('are ran in correct order', function (done) {
+ helpers.runMocha('retries/hooks.fixture.js', args, function (err, res) {
+ var lines, expected;
+
+ assert(!err);
+
+ lines = res.output.split(helpers.splitRegExp).map(function (line) {
+ return line.trim();
+ }).filter(function (line) {
+ return line.length;
+ }).slice(0, -1);
+
+ expected = [
+ 'before',
+ 'before each 0',
+ 'TEST 0',
+ 'after each 1',
+ 'before each 1',
+ 'TEST 1',
+ 'after each 2',
+ 'before each 2',
+ 'TEST 2',
+ 'after each 3',
+ 'before each 3',
+ 'TEST 3',
+ 'after each 4',
+ 'before each 4',
+ 'TEST 4',
+ bang + 'after each 5',
+ 'after'
+ ];
+
+ expected.forEach(function (line, i) {
+ assert.equal(lines[i], line);
+ });
+
+ assert.equal(res.code, 1);
+ done();
+ });
+ });
+
+ it('should exit early if test passes', function (done) {
+ helpers.runMochaJSON('retries/early-pass.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.passes, 1);
+ assert.equal(res.stats.failures, 0);
+ assert.equal(res.tests[0].currentRetry, 1);
+ assert.equal(res.stats.tests, 1);
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+
+ it('should let test override', function (done) {
+ helpers.runMochaJSON('retries/nested.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.passes, 0);
+ assert.equal(res.stats.failures, 1);
+ assert.equal(res.stats.tests, 1);
+ assert.equal(res.tests[0].currentRetry, 1);
+ assert.equal(res.code, 1);
+ done();
+ });
+ });
+
+ it('should not hang w/ async test', function (done) {
+ helpers.runMocha('retries/async.fixture.js', args, function (err, res) {
+ var lines, expected;
+
+ assert(!err);
+
+ lines = res.output.split(helpers.splitRegExp).map(function (line) {
+ return line.trim();
+ }).filter(function (line) {
+ return line.length;
+ }).slice(0, -1);
+
+ expected = [
+ 'before',
+ 'before each 0',
+ 'TEST 0',
+ 'after each 1',
+ 'before each 1',
+ 'TEST 1',
+ 'after each 2',
+ 'before each 2',
+ 'TEST 2',
+ 'after each 3',
+ 'after'
+ ];
+
+ expected.forEach(function (line, i) {
+ assert.equal(lines[i], line);
+ });
+
+ assert.equal(res.code, 0);
+ done();
+ });
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/suite.spec.js b/tests/lib/mocha-3.1.2/test/integration/suite.spec.js
new file mode 100644
index 0000000000..171a929ed1
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/suite.spec.js
@@ -0,0 +1,43 @@
+'use strict';
+
+var assert = require('assert');
+var run = require('./helpers').runMocha;
+var args = [];
+
+describe('suite w/no callback', function () {
+ this.timeout(1000);
+ it('should throw a helpful error message when a callback for suite is not supplied', function (done) {
+ run('suite/suite-no-callback.fixture.js', args, function (err, res) {
+ assert(!err);
+ var result = res.output.match(/no callback was supplied/) || [];
+ assert.equal(result.length, 1);
+ done();
+ });
+ });
+});
+
+describe('skipped suite w/no callback', function () {
+ this.timeout(1000);
+ it('should not throw an error when a callback for skipped suite is not supplied', function (done) {
+ run('suite/suite-skipped-no-callback.fixture.js', args, function (err, res) {
+ assert(!err);
+ var pattern = new RegExp('Error', 'g');
+ var result = res.output.match(pattern) || [];
+ assert.equal(result.length, 0);
+ done();
+ });
+ });
+});
+
+describe('skipped suite w/ callback', function () {
+ this.timeout(1000);
+ it('should not throw an error when a callback for skipped suite is supplied', function (done) {
+ run('suite/suite-skipped-callback.fixture.js', args, function (err, res) {
+ assert(!err);
+ var pattern = new RegExp('Error', 'g');
+ var result = res.output.match(pattern) || [];
+ assert.equal(result.length, 0);
+ done();
+ });
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/timeout.spec.js b/tests/lib/mocha-3.1.2/test/integration/timeout.spec.js
new file mode 100644
index 0000000000..4e0f989e86
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/timeout.spec.js
@@ -0,0 +1,18 @@
+'use strict';
+
+var assert = require('assert');
+var run = require('./helpers').runMochaJSON;
+var args = [];
+
+describe('this.timeout()', function () {
+ it('is respected by sync and async suites', function (done) {
+ run('timeout.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 0);
+ assert.equal(res.stats.failures, 2);
+ assert.equal(res.code, 2);
+ done();
+ });
+ });
+});
diff --git a/tests/lib/mocha-3.1.2/test/integration/uncaught.spec.js b/tests/lib/mocha-3.1.2/test/integration/uncaught.spec.js
new file mode 100644
index 0000000000..92e39c195e
--- /dev/null
+++ b/tests/lib/mocha-3.1.2/test/integration/uncaught.spec.js
@@ -0,0 +1,37 @@
+'use strict';
+
+var assert = require('assert');
+var run = require('./helpers').runMochaJSON;
+var args = [];
+
+describe('uncaught exceptions', function () {
+ it('handles uncaught exceptions from hooks', function (done) {
+ run('uncaught-hook.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 0);
+ assert.equal(res.stats.failures, 1);
+
+ assert.equal(res.failures[0].fullTitle,
+ 'uncaught "before each" hook');
+ assert.equal(res.code, 1);
+ done();
+ });
+ });
+
+ it('handles uncaught exceptions from async specs', function (done) {
+ run('uncaught.fixture.js', args, function (err, res) {
+ assert(!err);
+ assert.equal(res.stats.pending, 0);
+ assert.equal(res.stats.passes, 0);
+ assert.equal(res.stats.failures, 2);
+
+ assert.equal(res.failures[0].title,
+ 'fails exactly once when a global error is thrown first');
+ assert.equal(res.failures[1].title,
+ 'fails exactly once when a global error is thrown second');
+ assert.equal(res.code, 2);
+ done();
+ });
+ });
+});