react-test-context-provider
A function that allows you to specify context to pass to a child component (intended for testing only).
Installation
This module is distributed via npm which is bundled with node and should
be installed as one of your project's devDependencies
:
npm install --save-dev react-test-context-provider
Usage
var getContextProvider = var contextObject = color: 'blue' // the context you want to provide to the children componentsvar reactElement = // returns the react element as rendered with the given context
In this example, I'm using the Jest testing framework.
Button.js
{ // function components receive context as the second argument return <button style=background: color>children</button>}ButtonpropTypes = children: PropTypesanyisRequiredButtoncontextTypes = color: PropTypesstring
Button.test.js
LICENSE
MIT