React Router (v4)
Last updated
Was this helpful?
Last updated
Was this helpful?
This plugin sets up the context required for react-router
(v4) and exposes a history
instance so that tests can manipulate the URL. With this plugin enabled, it is possible to mount all react-router
components in your test, including <Link />
, <Route />
, etc.
Setup required peer dependencies: , , , and .
Install via yarn or npm
Add to plugins:
After adding the plugin to your mount
/shallow
, it can be used in your tests like so:
routerContext() => EnzymePlugin
EnzymePlugin
: The plugin which can be passed to createMount
/createShallow
.
This plugin also allows some configuration to be passed at mount-time:
routerConfig
(Object
[optional]): any of the configuration . For example, we can set the URL before our component mounts like so: