Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Added: initial run of tests with --watch. Closes #345

TJ Holowaychuk786a7a9d3bb4
diff --git a/bin/_mocha b/bin/_mocha
index 04d4e39c..3a7a903d 100755
--- a/bin/_mocha
+++ b/bin/_mocha
@@ -215,26 +215,30 @@ if (program.watch) {
, ' \033[96m◟ \033[90mwatching\033[0m'
];
- play(frames);
-
var watchFiles = utils.files(cwd);
+ function loadAndRun() {
+ load(files, function(){
+ run(suite, function(){
+ play(frames);
+ });
+ });
+ }
+
function purge() {
watchFiles.forEach(function(file){
delete require.cache[file];
});
}
+ loadAndRun();
+
utils.watch(watchFiles, function(){
purge();
stop()
suite = suite.clone();
ui = interfaces[program.ui](suite);
- load(files, function(){
- run(suite, function(){
- play(frames);
- });
- });
+ loadAndRun();
});
return;