Skip to content

Latest commit

 

History

History
61 lines (44 loc) · 1.33 KB

tape-ava.md

File metadata and controls

61 lines (44 loc) · 1.33 KB

Using enzyme with Tape and AVA

enzyme works well with Tape and AVA. Simply install it and start using it:

npm i --save-dev enzyme enzyme-adapter-react-16

Tape

import test from 'tape';
import React from 'react';
import { shallow, mount, configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

import Foo from '../path/to/foo';

configure({ adapter: new Adapter() });

test('shallow', (t) => {
  const wrapper = shallow(<Foo />);
  t.equal(wrapper.contains(<span>Foo</span>), true);
});

test('mount', (t) => {
  const wrapper = mount(<Foo />);
  const fooInner = wrapper.find('.foo-inner');
  t.equal(fooInner.is('.foo-inner'), true);
});

AVA

import test from 'ava';
import React from 'react';
import { shallow, mount, configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

import Foo from '../path/to/foo';

configure({ adapter: new Adapter() });

test('shallow', (t) => {
  const wrapper = shallow(<Foo />);
  t.is(wrapper.contains(<span>Foo</span>), true);
});

test('mount', (t) => {
  const wrapper = mount(<Foo />);
  const fooInner = wrapper.find('.foo-inner');
  t.is(fooInner.is('.foo-inner'), true);
});

Example Projects