【发布时间】:2020-06-29 23:16:08
【问题描述】:
我对 JS 比较陌生,无法弄清楚最新 create-react-app 中以下模板 jest 测试的第 2 行发生了什么:
test('renders learn react link', () => {
const { getByText } = render(<App />);
const linkElement = getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
渲染是否总是返回一个名为 getByText 的函数?这是解构吗?为什么要在第三行作为方法使用?
【问题讨论】:
标签: jestjs