enzymejs/chai-enzyme

TypeScript error - Property 'text' does not exist on type 'Include'.

raptoria opened this issue · 3 comments

It seems like something might be missing from @types/chai-enzyme? Besides the TypeScript error, the code runs fine..

My test:

  it('Has File', () => {
    const wrapper = render(<FileMenu />);
    expect(wrapper.find('.dropdown')).to.contain.text('File');  //line 17..
  });

ERROR in ./test/components/FileMenu/FileMenuTest.tsx
(17,50): error TS2339: Property 'text' does not exist on type 'Include'.

In the documentation, it shows:
expect(wrapper.find('#child')).to.contain.text('Te')

According to:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/chai-enzyme/index.d.ts

The Text attribute exists on Assertion and not Include (hence the error)
Contain, which is an Include, expects a selector as an argument

I'd file this on the dt repo, since those types aren't necessarily maintained by the chai-enzyme maintainers.

OK