如何导入笑话? [英] How to import jest?
本文介绍了如何导入笑话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我开玩笑的测试代码中摆脱掉全局变量.特别是describe
,it
和expect
I would like to get rid of globals in my jest test code. Specifically describe
, it
and expect
describe('Welcome (Snapshot)', () => {
it('Welcome renders hello world', () => {
...
});
});
所以我尝试添加
import {describe,it} from 'jest';
和
import jest from 'jest';
jest.describe( ...
jest.it( ...
和其他变体..
但是没有运气.
我应该如何使其正常工作?
How should I get it working?
推荐答案
最简单的解决方案是将jest: true
添加到eslint的env
配置中,如下所示:
The simplest solution for this is adding jest: true
to your env
config in eslint, like so:
"env": {
"browser": true,
"node": true,
"jasmine": true,
"jest": true,
"es6": true
},
这篇关于如何导入笑话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文