繁体   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