mirror of
https://github.com/plausible/analytics.git
synced 2025-01-07 10:38:44 +03:00
26 lines
745 B
TypeScript
26 lines
745 B
TypeScript
/** @format */
|
|
|
|
import { render, RenderOptions } from '@testing-library/react'
|
|
import { ReactNode } from 'react'
|
|
|
|
/**
|
|
* Makes the fake document in unit tests aware of some tailwind class definitions.
|
|
* Needed for the matcher option ({ hidden: false }) to function at least partially.
|
|
*/
|
|
const registerPartialTailwindStyle = () => {
|
|
const tailwindStyle = `.invisible { visibility: hidden; }`
|
|
|
|
const style = document.createElement('style')
|
|
style.innerHTML = tailwindStyle
|
|
document.head.appendChild(style)
|
|
}
|
|
|
|
const customRender = (ui: ReactNode, options: RenderOptions) => {
|
|
const output = render(ui, options)
|
|
registerPartialTailwindStyle()
|
|
return output
|
|
}
|
|
|
|
export * from '@testing-library/react'
|
|
export { customRender as render }
|