【发布时间】:2019-07-26 17:56:15
【问题描述】:
我是测试新手, 我试图了解是否可以测试从组件调度的 API 调用。 是否可以等待服务器的响应?
import React from 'react';
import { render, fireEvent, cleanup, waitForElement } from 'react-testing-library';
import 'jest-dom/extend-expect'
import App from 'src/app';
import { store } from 'stories/index.stories.js';
import { Provider, connect } from 'react-redux';
const renderComponent = () => (<App />);
it('renders correctly', () => {
const { container, getByText, queryAllByText, getByPlaceholderText } = renderComponent();
expect(container).not.toBeEmpty();
expect(getByText(/Discover/i)).toBeTruthy();
const discoverBtn = getByText(/Discover/i);
fireEvent.click(discoverBtn); // this will dispatch an action from the component
//what should i do next ?
});
【问题讨论】:
-
你能添加你目前的代码吗?这些小信息对您的帮助很重要
-
我正在编辑问题
-
这取决于你点击按钮时应该发生什么
标签: jestjs react-testing-library