簡體   English   中英

無法使用Mocha正確配置單元測試

[英]Cant configure unit tests correctly with mocha

我正在嘗試在打字稿項目上配置Mocha,但不能正常工作我正在使用書:打字稿設計模式,第1章。

當我運行摩卡咖啡時,它說:

警告:找不到任何匹配模式的測試文件:out / test /未找到測試文件

摩卡

--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();
}); });

項目結構

基於該錯誤,mocha似乎正在嘗試在/out目錄中查找測試。 首先,嘗試從mocha.opts刪除/out/test或將其替換為src/test以查看是否可以解決路徑問題。

您也可以嘗試將mocha.js移至/src/test目錄,然后將mocha.opts移至/src目錄。

然后,在運行mocha時,請確保您從項目的根目錄運行(在這種情況下,該目錄似乎是src

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM