☕️ Classic, reliable, trusted test framework for Node.js and the browser
Sort tests files using argument flag
Valentin Agachi04adb433e71a
diff --git a/Makefile b/Makefileindex ed6d8083..6c555012 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-requires test-reporters test-only+test-all: test-bdd test-tdd test-qunit test-exports test-unit test-grep test-jsapi test-compilers test-sort test-glob test-requires test-reporters test-onlytest-jsapi:@node test/jsapi@@ -134,6 +134,12 @@ test-only:--ui qunit \test/acceptance/misc/only/qunit+test-sort:+ @./bin/mocha \+ --reporter $(REPORTER) \+ --sort \+ test/acceptance/sort+non-tty:@./bin/mocha \--reporter dot \diff --git a/bin/_mocha b/bin/_mochaold mode 100755new mode 100644index ba1f80b7..f6bf8957--- a/bin/_mocha+++ b/bin/_mocha@@ -77,6 +77,7 @@ program.option('-d, --debug', "enable node's debugger, synonym for node --debug").option('-b, --bail', "bail after first test failure").option('-A, --async-only', "force all tests to take a callback (async)")+ .option('-S, --sort', "sort test files").option('--recursive', 'include sub directories').option('--debug-brk', "enable node's debugger breaking on the first line").option('--globals <names>', 'allow the given comma-delimited global [names]', list, [])@@ -286,6 +287,10 @@ files = files.map(function(path){return resolve(path);});+if (program.sort) {+ files.sort();+}+// --watchif (program.watch) {diff --git a/test/acceptance/sort/alpha.js b/test/acceptance/sort/alpha.jsnew file mode 100644index 00000000..365f39cd--- /dev/null+++ b/test/acceptance/sort/alpha.js@@ -0,0 +1,7 @@+describe('alpha', function(){+ it('should be executed first', function(){+ if (global.beta) {+ throw new Error('alpha was not executed first');+ }+ });+});\ No newline at end of filediff --git a/test/acceptance/sort/beta.js b/test/acceptance/sort/beta.jsnew file mode 100644index 00000000..3de3e0cc--- /dev/null+++ b/test/acceptance/sort/beta.js@@ -0,0 +1,5 @@+describe('beta', function(){+ it('should be executed second', function(){+ global.beta = 1;+ });+});\ No newline at end of file