Jest test returns an empty body

Viewed 698

When I debug() this test it returns an empty body. Does anyone know where I'm going wrong? It should render a component with a grid for user inputs. Here are the propTypes for the component:

CompanyInfoInputs.propTypes = {
  onChange: PropTypes.func.isRequired,
  loading: PropTypes.bool.isRequired,
  fieldValues: PropTypes.object.isRequired,
  dropdownError: PropTypes.bool
};

CompanyInfoInputs.defaultProps = {
  dropdownError: false
};

NewCompanyModal.propTypes = {
  open: PropTypes.bool.isRequired,
  handleClose: PropTypes.func.isRequired
};

export default NewCompanyModal;

Here is the test as it stands currently.

import React from 'react';
import { render } from '@testing-library/react';
import { ApolloProvider } from '@apollo/react-hooks';
import { client } from '../../../../../client';
import NewCompanyModal from '../../../../../components/reusable_components/company/NewCompanyModal';

const RComponent = props => {
  const companyModalOpen = true;
  const loading = false;
  return (
    <ApolloProvider client={client}>
      <NewCompanyModal
        open={companyModalOpen}
        handleClose={() => {}}
        loading={loading}
        {...props}
      />
    </ApolloProvider>
  );
};

beforeEach(() => {
  jest.resetAllMocks();
});

describe('Testing Company Reusable Components', () => {
  describe('Testing <NewCompanyModal />', () => {
    it('should handle basic component rendering', async () => {
      const { debug, getByText, getAllByLabelText } = render(<RComponent />);
      // expect(getByText('Register a New Company')).toBeTruthy();
      // expect(getAllByLabelText('Company Legal Name')).toBeTruthy();
      debug();
    });
  });
});

returns

<body>
   <div />
</body>

EDIT: I added

describe('Testing Company Reusable Components', () => {
  describe('Testing <NewCompanyModal />', () => {
    it('should handle basic component rendering', async () => {
      const { debug } = render(<RComponent />);
      await act(() => wait());
      debug();
    });
  });
});

which seemed to allow the page to render although now I have a network error "[Network error]: No Cognito Identity pool provided for unauthenticated access" which I guess is a project specific issue.

0 Answers
Related