2017-02-20 86 views
6

如何告訴Mocha在哪裏尋找我的測試文件?我的測試文件不駐留在標準項目根目錄./test文件夾中。我的測試坐在Modules/.*/Tests/告訴摩卡在哪裏尋找測試文件

我試圖使用--grep命令行參數,但我有一種感覺,這個參數尋找測試NAMES不是測試文件名。

mocha --grep Modules\/.*\/Tests

上面的命令給出了錯誤:

Warning: Could not find any test files matching pattern: test
No test files found

回答

12

你一定要配合,不僅目錄而且其文件。另外,不需要grep,只用--

mocha -- Modules/**/Tests/*.js 
// or `mocha -- Modules/Tests/*.js` (I am not sure because you didn't give the project hierarchy)