({ body: { customer } } = await callCreateCustomer({
email: createRandomEmailAddress(),
key: 999,
password: 'password',
}));
Run Code Online (Sandbox Code Playgroud)
我不明白当您拥有()
整个表情时意味着什么?
它有什么作用?
我跑了我的测试,这是我收到的:
---------------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
---------------|----------|----------|----------|----------|-------------------|
All files | 100 | 0 | 100 | 100 | |
Search | 100 | 100 | 100 | 100 | |
index.js | 100 | 100 | 100 | 100 | |
SearchResults | 100 | 0 | 100 | 100 | |
index.js | 100 | 0 | 100 | 100 | 4 |
---------------|----------|----------|----------|----------|-------------------|
Test …
我有一个React容器,我在其中进行API调用,并希望能够使用jest和酶测试它,但不确定如何.
这是我的代码:
import React from "react";
import Search from "../../components/Search";
import { API_KEY } from "../../../config";
class SearchContainer extends React.Component {
state = {
articles: []
};
performSearch = event => {
fetch(
`http://content.guardianapis.com/search?q=${event}&api-key=${API_KEY}`
)
.then(response => response.json())
.then(data => this.setState({ articles: data.response.results }));
};
render() {
return (
<Search
performSearch={this.performSearch}
articles={this.state.articles}
/>
);
}
}
export default SearchContainer;
Run Code Online (Sandbox Code Playgroud) javascript ×3
jestjs ×2
reactjs ×2
api ×1
enzyme ×1
eslint ×1
tdd ×1
testing ×1
unit-testing ×1