Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shallow does not find direct child when inside React.Fragment #1664

Closed
sepo27 opened this issue May 29, 2018 · 4 comments · Fixed by #1733
Closed

Shallow does not find direct child when inside React.Fragment #1664

sepo27 opened this issue May 29, 2018 · 4 comments · Fixed by #1733

Comments

@sepo27
Copy link

sepo27 commented May 29, 2018

Describe the bug
Shallow should find direct child when inside React.Fragment.
(At least it does so for indirect descendants).

To Reproduce

import * as React from 'react';
import {shallow} from 'enzyme';

const MyCom = () => (
  <div className="container">
    <React.Fragment>
      <span>A span</span>
    </React.Fragment>
  </div>
);

describe('enzyme shallow', () => {
  it('test#1: should find descendant span inside fragment ', () => {
    const myCom = shallow(<MyCom />);
    expect(myCom.find('.container span')).toHaveLength(1);
  });

  // TEST FAILS
  it('test#2: should find direct child span inside fragment', () => {
    const myCom = shallow(<MyCom />);
    expect(myCom.find('.container > span')).toHaveLength(1);
  });
});

Expected behavior
Expect test#2 to pass.

Desktop (please complete the following information):

  • OS: Ubuntu 16.04 LTS GNOME
  • Browser: X
  • Version: X

Additional context
Tests are failing inside Jest.

@mykhailo-riabokon
Copy link
Contributor

Hi @paska27

There is an open issue issue for React 16 support and as far as I see React.Fragment support is in progress. So, please check for updates.

@sepo27
Copy link
Author

sepo27 commented Jun 8, 2018

Thanks. Will close this one.

@sanketkalawade
Copy link

anybody.. please help me with this issue? (I'm new to enzyme)

@ljharb
Copy link
Member

ljharb commented Oct 4, 2019

@sanketkalawade please file a new issue if you're having trouble; this was fixed over a year ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants