开玩笑的全局变量示例 [英] jest global variable example
本文介绍了开玩笑的全局变量示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以举例说明如何使用玩笑全局变量吗?
Can someone give an example on how to use jest globals?
{
...
"jest": {
"globals": {
"__DEV__": true,
}
}
...
}
我是在package.json文件中指定全局变量还是使用js文件创建一个应在其中定义全局变量的文件夹?
Do I specify the globals in the package.json file or do I create a folder with a js file where the globals should be defined?
谢谢
推荐答案
是的.您将全局变量放在package.json中.例如,以下是默认的本机笑话配置的摘录:
Yep. You put the globals in the package.json. For example, here's an excerpt from the default react-native jest configuration:
"jest": {
"globals": {
"__DEV__": true,
"__RCTProfileIsProfiling": false
},
...
},
这将在运行测试时使变量全局可用.
This will make the variables available globally when the tests are run.
这篇关于开玩笑的全局变量示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文