【问题标题】:mocha is not finding my path when using mocha.opts使用 mocha.opts 时 mocha 找不到我的路径
【发布时间】:2016-10-31 06:43:35
【问题描述】:

我发现了一个great answer,关于如何让 mocha 识别我的测试文件位于另一个路径并递归遍历该路径 - 在 ./test 文件夹中创建 mocha.opts。但是,我对文件有一些问题。这是我的 mocha.opts 文件中的内容:

services/endpoints
--recursive

测试文件本身(200Tests.js、400Tests.js 等)存在于各种路径中:

./test/services/endpoints/
                    |---users
                    |---persons
                    |---|---findByName
                    |---|---|---200Tests.js
                    |---|---|---400Tests.js
                    |---|---findById
                    |---|---|---200Tests.js
                    |---|---|---400Tests.js

等等

从我的项目根目录,我从终端发出mocha 并得到:Error: cannot resolve path (or pattern) 'services/endpoints'。我做错了什么或遗漏了什么?

【问题讨论】:

    标签: mocha.js


    【解决方案1】:

    在您的 mocha.opts 文件中使用 test/services/endpoints

    Mocha 解释路径的目录是启动mocha 可执行文件的目录,通常是项目的顶层而不是test 子目录。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-05
      • 1970-01-01
      • 1970-01-01
      • 2019-09-02
      • 2011-09-30
      • 2014-10-24
      相关资源
      最近更新 更多