Node.js:标识为自动化testing用例执行而修改的文件

我目前使用nodemon或supervisor进行自动服务器重启和自动testing用例执行。 但是目前我的要求是在certain files改变时run specific test cases 。 例如,如果app\models\user.js被修改,我想要test\model\user-test.js被执行。

我为了实现我需要确定哪些是被修改的文件。 我怎样才能达到使用nodemonsupervisor

我不知道你是否可以用nodemon或supervisor来做到这一点,但你总是可以自己写:

 var watch = require('watch'); function methodToDoTestOnFile(file) { //IMPLEMENT } watch.createMonitor(filesToWatch, function (monitor) { monitor.on('changed', function (f) { //do some test on f methodToDoTestOnFile(f) }); });