styled-enzyme
Apply themes to your enzyme tests - the easy way.
Based on jest-styled-components and @sfitzpatrick/enzyme-context-helpers
Installation
npm i -D styled-enzyme
API
init()
Set the defaultTheme
to use with shallowWithTheme
, mountWithTheme
and renderWithTheme
.
The default theme is an empty object, so it is highly encouraged to provide your own.
; ;
shallowWithTheme
Shallowly renders your component with the default theme using enzyme's shallow()
function.
If you want to use a theme different from the default theme you may pass that as the second
argument;
; const shallowDefault = ;const customShallow = ;
A convenient shallow
alias for shallowWithTheme
has been provided.
; const shallowDefault = ;const customShallow = ;
mountWithTheme
Fully renders your component with the default theme using enzyme's mount()
function.
If you want to use a theme different from the default theme you may pass that as the second
argument;
; const mountedDefault = ;const mountedCustom = ;
A convenient mount
alias for mountWithTheme
has been provided.
; const mountedDefault = ;const mountedCustom = ;
renderWithTheme
Create a json snapshot using react-test-renderer
with the default theme. If you want to
use a theme different from the default theme you may pass that as the second argument;
; const themedSnapshot = ;const customThemedSnapshot = ;
A convenient render
alias for renderWithTheme
has been provided.
; const themedSnapshot = ;const customThemedSnapshot = ;