API
createMount(plugins) => (node: React.ReactElement, options? Object) => ContextReactWrapper
createMount(plugins) => (node: React.ReactElement, options? Object) => ContextReactWrapper
Arguments
plugins
(Object
): an object where the keys are names of your choice and the values areenzyme-context
MountPlugin
s.
Returns
A mount function: (node: React.ReactElement, options?: Object) => ContextReactWrapper
: A function that takes the same arguments as mount but can also accept additional options
(as specified by the provided plugins
.)
Arguments
node
(React.ReactElement
): The node to renderoptions
(Object
[optional]): The same options that can be passed to enzyme's mount plus any options the plugins you've added handle.
Returns
A
ReactWrapper
with the following attributes:[keyof plugins]: EnzymePlugin['controller']
: the returnedReactWrapper
will have a key that matches each key in theplugins
you provide. The value will be whatevercontroller
the plugin provides. For example, theenzyme-context-redux
plugin provides aStore
; theenzyme-context-react-router-4
plugin provides aHistory
.
Example
test-utils/enzyme.ts
MyComponent.spec.tsx
createShallow(plugins) => (node: React.ReactElement, options? Object) => ContextShallowWrapper
createShallow(plugins) => (node: React.ReactElement, options? Object) => ContextShallowWrapper
Arguments
plugins
(Object
): an object where the keys are names of your choice and the values areenzyme-context
MountPlugin
s.
Returns
A shallow function: (node: React.ReactElement, options?: Object) => ContextShallowWrapper
: A function that takes the same arguments as shallow but can also accept additional options
(as specified by the provided plugins
.)
Arguments
node
(React.ReactElement
): The node to renderoptions
(Object
[optional]): The same options that can be passed to enzyme's shallow plus any options the plugins you've added handle.
Returns
An
ShallowWrapper
with the following attributes:[keyof plugins]: EnzymePlugin['controller']
: the returned object will have a key that matches each key in theplugins
you provide. The value will be whatevercontroller
the plugin provides. For example, theenzyme-context-redux
plugin provides aStore
; theenzyme-context-react-router-4
plugin provides aHistory
.
Example
test-utils/enzyme.ts
MyComponent.spec.tsx
Last updated