玩笑测试返回一个空主体

Bil*_*man 5 testing reactjs jestjs react-testing-library

当我进行debug()此测试时,它返回一个空主体。有谁知道我哪里出错了?它应该呈现一个带有网格的组件以供用户输入。以下是propTypes该组件的信息:

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;
Run Code Online (Sandbox Code Playgroud)

这是目前的测试。

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();
    });
  });
});
Run Code Online (Sandbox Code Playgroud)

回报

<body>
   <div />
</body>
Run Code Online (Sandbox Code Playgroud)

编辑:我添加了

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

这似乎允许页面呈现,尽管现在我有一个网络错误“[网络错误]:没有为未经身份验证的访问提供Cognito身份池”,我猜这是一个项目特定的问题。