I'm writing a test using Enzyme for React.
My test is extremely straightforward:
import OffCanvasMenu from '../index';
import { Link } from 'react-router';
import expect from 'expect';
import { shallow, mount } from 'enzyme';
import sinon from 'sinon';
import React from 'react';
describe('<OffCanvasMenu />', () => {
it('contains 5 <Link /> components', () => {
const wrapper = shallow(<OffCanvasMenu />);
expect(wrapper.find(<Link />)).to.have.length(5);
});
});
This code is basically taken directly from airbnb/enzyme docs, but returns the error:
FAILED TESTS:
<OffCanvasMenu />
✖ contains 5 <Link /> components
Chrome 52.0.2743 (Mac OS X 10.11.6)
TypeError: Cannot read property 'have' of undefined
I'm a little unclear on what I'm doing differently from the docs. Any guidance greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire