☕️ Classic, reliable, trusted test framework for Node.js and the browser
Use compilers with requires
Mal Gratyfecad636c33c
diff --git a/Makefile b/Makefileindex 4c089c22..055f7c5c 100644--- a/Makefile+++ b/Makefile@@ -32,7 +32,7 @@ lib-cov:test: test-unit-test-all: test-bdd test-tdd test-qunit test-exports test-unit test-grep test-jsapi test-compilers test-glob+test-all: test-bdd test-tdd test-qunit test-exports test-unit test-grep test-jsapi test-compilers test-glob test-requirestest-jsapi:@node test/jsapi@@ -51,6 +51,16 @@ test-compilers:test/acceptance/test.coffee \test/acceptance/test.foo+test-requires:+ @./bin/mocha \+ --reporter $(REPORTER) \+ --compilers coffee:coffee-script \+ --require test/acceptance/require/a.js \+ --require test/acceptance/require/b.coffee \+ --require test/acceptance/require/c.js \+ --require test/acceptance/require/d.coffee \+ test/acceptance/require/require.js+test-bdd:@./bin/mocha \--reporter $(REPORTER) \diff --git a/bin/_mocha b/bin/_mochaindex 73295051..735d009a 100755--- a/bin/_mocha+++ b/bin/_mocha@@ -43,6 +43,12 @@ var files = [];var globals = [];+/**+ * Requires.+ */++var requires = [];+/*** Images.*/@@ -148,7 +154,7 @@ module.paths.push(cwd, join(cwd, 'node_modules'));program.on('require', function(mod){var abs = exists(mod) || exists(mod + '.js');if (abs) mod = resolve(mod);- require(mod);+ requires.push(mod);});// mocha.opts support@@ -255,6 +261,12 @@ program.compilers.forEach(function(c) {var re = new RegExp('\\.(' + extensions.join('|') + ')$');+// requires++requires.forEach(function(mod) {+ require(mod);+});+// filesvar files = []diff --git a/test/acceptance/require/a.js b/test/acceptance/require/a.jsnew file mode 100644index 00000000..592d8274--- /dev/null+++ b/test/acceptance/require/a.js@@ -0,0 +1,2 @@+global.required = (global.required || [])+global.required.push('a.js')diff --git a/test/acceptance/require/b.coffee b/test/acceptance/require/b.coffeenew file mode 100644index 00000000..045cc759--- /dev/null+++ b/test/acceptance/require/b.coffee@@ -0,0 +1,2 @@+global.required ?= []+global.required.push 'b.coffee'diff --git a/test/acceptance/require/c.js b/test/acceptance/require/c.jsnew file mode 100644index 00000000..4e681373--- /dev/null+++ b/test/acceptance/require/c.js@@ -0,0 +1,2 @@+global.required = (global.required || [])+global.required.push('c.js')diff --git a/test/acceptance/require/d.coffee b/test/acceptance/require/d.coffeenew file mode 100644index 00000000..d5ebbf60--- /dev/null+++ b/test/acceptance/require/d.coffee@@ -0,0 +1,2 @@+global.required ?= []+global.required.push 'd.coffee'diff --git a/test/acceptance/require/require.js b/test/acceptance/require/require.jsnew file mode 100644index 00000000..74dd0eb5--- /dev/null+++ b/test/acceptance/require/require.js@@ -0,0 +1,10 @@++describe('require test', function(){+ it('should require args in order', function(){+ var req = global.required;+ req.indexOf('a.js').should.equal(0);+ req.indexOf('b.coffee').should.equal(1);+ req.indexOf('c.js').should.equal(2);+ req.indexOf('d.coffee').should.equal(3);+ })+});