Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 当测试反应组分时,酶是如何与Jest一起工作的?_Reactjs_Unit Testing_Testing_Jestjs_Enzyme - Fatal编程技术网

Reactjs 当测试反应组分时,酶是如何与Jest一起工作的?

Reactjs 当测试反应组分时,酶是如何与Jest一起工作的?,reactjs,unit-testing,testing,jestjs,enzyme,Reactjs,Unit Testing,Testing,Jestjs,Enzyme,我正在用酶和CreateReact应用程序,我有点困惑它们到底是如何相互作用的。我是在我的断言中使用酶API,还是在Jest的断言中使用酶API,还是两者的组合 例如,这是我的测试代码: import React from 'react'; import Console from './Console'; import {shallow} from 'enzyme'; it('renders', () => { const wrapper = shallow(<Console

我正在用酶和CreateReact应用程序,我有点困惑它们到底是如何相互作用的。我是在我的断言中使用酶API,还是在Jest的断言中使用酶API,还是两者的组合

例如,这是我的测试代码:

import React from 'react';
import Console from './Console';
import {shallow} from 'enzyme';

it('renders', () => {
  const wrapper = shallow(<Console />);

  expect(wrapper.equals(<div id="console" />)).toBe(true);
});
从“React”导入React;
从“./Console”导入控制台;
从“酶”导入{shall};
它('呈现',()=>{
常量包装器=浅();
expect(wrapper.equals()).toBe(true);
});
.equals()
似乎是一个,但我在Ezyme的API文档中找不到.toBe()


更广泛地说,测试运行程序、框架和断言库究竟是如何交互的?我读过多篇文章,有很多问题和答案,但我还是不太确定。谢谢大家!

在这种情况下,为什么我不需要在我的测试文件中导入或要求“jest”呢?我只是从'enzyme'模块导入'shall'-这是否意味着我只限于'shall'下的酶API?这是因为当您配置jest时,它会添加一个全局API列表,请检查。