【发布时间】:2020-03-17 17:46:11
【问题描述】:
我有以下在浏览器中正确执行的行
eval(Babel.transform(template, { presets: ['react'] }).code);
但是当我运行玩笑测试时,我得到了ReferenceError: React is not defined
我错过了什么?
更多信息: 在测试文件中我有以下内容:
const wrapper = shallow(<MyComponent/>);
const instance = wrapper.instance();
instance.componentFunction(...)
然后componentFunction 有eval(Babel.transform(template, { presets: ['react'] }).code); 行,其中template 是它从测试文件中获取的东西,可以是<span>...</span> 之类的东西
如果需要更多详细信息,请告诉我
【问题讨论】:
标签: reactjs jestjs babel-jest