我想測試反應成分:測試反應成分withing反應路由器
export class IdentityPage extends React.Component<PageProps, State> {
constructor(props: PageProps) {
super(props);
}
componentDidMount() { this.reload(this.props.routeParams.id); }
render(){....}
}
這是在使用反應路由器這樣的:
<Router history={hashHistory}>
<Route path="/">
<Route path="Identities">
<Route path=":action/:id" component={IdentityPage} />
</Route>
</Route>
</Router>
然而,測試失敗:
屬性 'ID' 10無法讀取的不確定
,當我嘗試運行:
let pageProps: PageProps = {
params: {
action: "view",
id: "0"
}
};
let instance = TestUtils.renderIntoDocument(React.createElement(IdentityPage, pageProps));