Skip to content

attr doesn't work with shallow (only with mount) #205

@cuongluu8

Description

@cuongluu8

For example

const ReportLink = ({ href }) => (
    <a href={href}>This is a link</a>
);

const props = { href: '/link/to' }
const reportLink = shallow(<ReportLink {...props}/>);
expect(reportLink).to.have.attr('href').equal(props.href);

Gives the following error
Window is not a constructor (evaluating '(0, _cheerio2.default)(this.wrapper.html())')

Works fine if I use mount instead of shallow. Documentation suggests that attr is support in a shallow render.

Using chai-enzyme v0.7.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions