簡體   English   中英

使用Mocha / chai進行測試時找不到模塊“ it”

[英]Cannot find module 'it' when testing with mocha/chai

我有一個簡單的測試

import {topNavigationLinks} from './navigation-links.js';
import {assert,should,expect=} from 'chai';
import {mocha} from 'mocha';


describe('Navigation Links', () => {
    it('should have the right value', function () {
      expect(topNavigationLinks(123).to.equal([]));
    });
});

但我不斷收到這個錯誤

Error: Cannot find module 'it'

有什么線索嗎?

您不需要在要進行測試的文件中添加mocha

import * as mocha from 'mocha';

編輯

您也不應該在摩卡咖啡中使用箭頭功能

錯誤是將node_modules作為我的Mocha腳本的一部分。 因此,它遍歷了所有的node_modules,顯然沒有找到it語句。 刪除那照顧它

暫無
暫無

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

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