Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Fix an issue and add relevant tests when describe and xdescribe fail when not supplied with a callback (issue #1744).

antone22c40751f1a
diff --git a/test/integration/fixtures/suite/describe.callback.js b/test/integration/fixtures/suite/describe.callback.js
new file mode 100644
index 00000000..de55b358
--- /dev/null
+++ b/test/integration/fixtures/suite/describe.callback.js
@@ -0,0 +1 @@
+describe('a suite without a callback');
diff --git a/test/integration/fixtures/suite/xdescribe.callback.js b/test/integration/fixtures/suite/xdescribe.callback.js
new file mode 100644
index 00000000..c5bca84a
--- /dev/null
+++ b/test/integration/fixtures/suite/xdescribe.callback.js
@@ -0,0 +1 @@
+xdescribe('a pending suite without a callback');
diff --git a/test/integration/suite.js b/test/integration/suite.js
new file mode 100644
index 00000000..369f08a7
--- /dev/null
+++ b/test/integration/suite.js
@@ -0,0 +1,29 @@
+var assert = require('assert');
+var run = require('./helpers').runMocha;
+var args = [];
+
+describe('.describe()', function() {
+ this.timeout(1000);
+ it('should throw a helpful error message when a callback for describe is not supplied', function(done) {
+ run('suite/describe.callback.js', args, function(err, res) {
+ assert(!err);
+ pattern = new RegExp('TypeError: a callback is not supplied', 'g');
+ var result = res.output.match(pattern) || [];
+ assert.equal(result.length, 1);
+ done();
+ });
+ });
+});
+
+describe('.xdescribe()', function() {
+ this.timeout(1000);
+ it('should not throw an error when a callback for xdescribe is not supplied', function(done) {
+ run('suite/xdescribe.callback.js', args, function(err, res) {
+ assert(!err);
+ pattern = new RegExp("Error", 'g');
+ var result = res.output.match(pattern) || [];
+ assert.equal(result.length, 0);
+ done();
+ });
+ });
+});