propTypes 在我定义组件的主JS文件中起作用。是我期待的。但是在我的test.js 中 describe模块中也进行check 干扰了我的测试。我在test.js 并没有引入 prop-type。如何能取消在test.js 中的check
test.js
describe('Search', () => {
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<Search>Search</Search>, div);
});
test('has a valid snapshot', () => {
const component = renderer.create(
<Search>Search</Search>
);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
});
});
这些块只是做一些基本验证。没有传入参数。导致控制台中一直提示 required的字段是undefined