expect-proptypes
This library extends expect to allow for assertions about object shapes, using React's PropTypes library or the standalone proptypes library on npm.
Usage
const PropTypes = ; // Extend expect with this library.const expect = ;const expectPropTypes = expect; // Find some object you want to check the shape ofconst obj = num: 1 foo: "bar"; // `toHaveProps` does not allow additional props; // `toContainProps` allows additional propses;
How can I get better error logging?
If your proptypes have a property __name__
which is a string, this will be used in the error logs.
What if I want more detailed types?
Consider using my library extended-proptypes, which adds many useful validators, such as dates,constants, constants and regex matching for strings and object keys.