【问题标题】:Cant configure unit tests correctly with mocha无法使用 mocha 正确配置单元测试
【发布时间】:2017-04-10 04:22:02
【问题描述】:

我正在尝试在 typescript 项目上配置 mocha,但无法正常工作 我正在使用书籍:Typescript 设计模式,第 1 章。

当我运行 mocha 时,它会说:

警告:找不到任何匹配模式的测试文件:out/test/ No 找到测试文件

mocha.opts

--require ./test/mocha.js
out/test/

mocha.js

require('chai').should();

starter.js

describe('some feature', () => {
     it('should pass', () => {
       'foo'.should.not.equal('bar');
     });
     it('should error', () => {
       (() => {
         throw new Error();
       }).should.throw();
}); });

【问题讨论】:

    标签: javascript typescript mocha.js


    【解决方案1】:

    根据错误,mocha 似乎正在尝试在/out 目录中查找测试。首先,尝试从mocha.opts 中删除/out/test 或将其替换为src/test,看看是否可以解决路径问题。

    您也可以尝试将mocha.js 移动到/src/test 目录,然后将mocha.opts 移动到/src 目录。

    然后,在运行 mocha 时,请确保从项目的根目录运行(在本例中似乎是 src

    【讨论】:

      猜你喜欢
      • 2020-02-05
      • 2016-04-17
      • 1970-01-01
      • 1970-01-01
      • 2019-09-03
      • 1970-01-01
      • 2016-03-25
      • 1970-01-01
      • 2018-02-01
      相关资源
      最近更新 更多