Unable to find only Button Component for test

I have the following component and trying to perform tests on it.

I am able to find all other Components such as Element and Table.

But there is no result for finding Button object even though there are 2 of those.

Why is that the case?

To note Button, Element and Table component here are all custom components of mine.

Component being tested

export const MyComponent = () => (
    <div style={{ margin: 20 }}>
      <Button onClick={() => {}}>
        Click Me!
      <Button onClick={() => {}}>
        Click Me!

    <Element name="name">
      <Table name="name" />

export default MyComponent;

My test

describe('test page', () => {

     it('should click', () => {

    const mockSelectorToggle = jest.fn();
    const defaultProps = {};
    const initialise = props => shallow(<MyComponent {...defaultProps} {...props} />);
    const wrapper = initialise();

    // all the following found

    // nothing found. Why only Button not findable?
    // wrapper.find('Button')
    // wrapper.find('div').find('div').find('Button')

    // looking to test it this way

1 thought on “Unable to find only Button Component for test”

Leave a Comment