如何导入“描述"?和“它"从打字稿中的摩卡咖啡? [英] How to import "describe" and "it" from mocha in TypeScript?

查看:96
本文介绍了如何导入“描述"?和“它"从打字稿中的摩卡咖啡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认情况下,在TypeScript中导入mocha时,它将describeit(以及其他一些)引入全局名称空间.

By default, when importing mocha in TypeScript, it brings in describe and it (and some others) into the global namespace.

是否可以引入诸如import {describe, it} from 'mocha'之类的特定进口商品?

Is there a way to bring in specific imports like import {describe, it} from 'mocha'?

推荐答案

安装mocha及其类型:

Install mocha and its types:

npm install mocha --save-dev
npm install @types/mocha --save-dev

然后,只需将Mocha导入您的测试文件中即可:

Then, simply import mocha in your test files:

import 'mocha';

describe('my test', () => {
  it('does something', () => {
    // your test
  });
});

这篇关于如何导入“描述"?和“它"从打字稿中的摩卡咖啡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆