Created
January 10, 2019 19:50
-
-
Save denieler/2074867f33275720fb54614b4c96bd10 to your computer and use it in GitHub Desktop.
Custom render function for react-testing-library for jest snapshots with jss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { render } from 'react-testing-library' | |
import JssProvider from 'react-jss/lib/JssProvider' | |
const generateClassName = (rule, styleSheet) => | |
`${styleSheet.options.classNamePrefix}-${rule.key}` | |
const customRender = (node, options) => { | |
return render( | |
<JssProvider generateClassName={generateClassName}> | |
{node} | |
</JssProvider>, | |
options | |
) | |
} | |
// re-export everything | |
export * from 'react-testing-library' | |
// override render method | |
export { customRender as render } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment