describe-component
describe-component copied to clipboard
Add context helpers
describeComponent
should expose setContext
and context
helpers that work the same as setProps
and props
, but for context.
As of 1.1.0, you can pass options for enzyme's mount
, shallow
, or render
functions into mountWrapper
, shallowWrapper
, or renderWrapper
. This lets you set context like this:
describeComponent(MyComponent, ({ mountWrapper }) => {
mountWrapper({ context: { some: "context", goes: "here" } });
});
However, the usage can be a bit awkward, because the context set in the first invocation of mountWrapper
or shallowWrapper
carries over to the next time mountWrapper
or shallowWrapper
is called (since the result is memoized). For this reason, I'd still like to eventually add setContext
and context
- but using enzyme's options is an easy workaround in the meantime.