jeudi 24 mai 2018

How does Enzyme work together with Jest when testing React components?

I am using Enzyme with a create-react-app, and I'm a little confused as to how exactly they interplay. Am I using Enzyme API in my assertions, or Jest's, or a combination of both?

For instance, this is my test code:

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);
});

.equals() seems to be an Enzyme API, but I can't find .toBe()` anywhere in Enzyme's API documentation.

On a broader note, how exactly do test runners, frameworks, and assertion libraries interact? I've read multiple articles and SO questions and answers, but I'm still not too sure. Thank you!

Aucun commentaire:

Enregistrer un commentaire