我正在尝试用React和Jest编写简单的测试.
零件:
import React from "react"; class Task extends React.Component { render() { let onDelete = this.props.onDelete; return (
{this.props.description}
测试
import React from 'react'; import Task from '../src/components/Task'; import renderer from 'react-test-renderer'; test('Task should require properties', () => { const component = renderer.create( //this will give me React warnings which I would like to assert); });
现在我想断言title
,taskId
并且onDelete
是Task
组件所必需的.我将得到React警告,不指定它们(或传递不同的类型).