Skip to content

armgit / mocha

Public Imported from GitHub
0

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

1794 test case

Joao Moreno1d0ff9f418c8
diff --git a/test/integration/fixtures/regression/1794/issue-1794.js b/test/integration/fixtures/regression/1794/issue-1794.js
new file mode 100644
index 00000000..1a1637f3
--- /dev/null
+++ b/test/integration/fixtures/regression/1794/issue-1794.js
@@ -0,0 +1,3 @@
+test('pass', function() {
+ // pass
+});
diff --git a/test/integration/fixtures/regression/1794/simple-ui.js b/test/integration/fixtures/regression/1794/simple-ui.js
new file mode 100644
index 00000000..024b0977
--- /dev/null
+++ b/test/integration/fixtures/regression/1794/simple-ui.js
@@ -0,0 +1,26 @@
+var Mocha = require('mocha');
+ Suite = require('mocha/lib/suite'),
+ Test = require('mocha/lib/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('mocha/lib/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;
+ };
+ });
+};
\ No newline at end of file
diff --git a/test/integration/regression.js b/test/integration/regression.js
index 5e2d863a..216fcc74 100644
--- a/test/integration/regression.js
+++ b/test/integration/regression.js
@@ -30,4 +30,13 @@ describe('regressions', function() {
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.js', args, function(err, res) {
+ assert.equal(res.code, 0, 'Custom UI should be loaded');
+ done();
+ });
+ });
});