I'm testing a UI with the React Testing Library. Wondering if there is any way (including incorporating a separate package) to render the page being created by a test in my browser as I run the test. I'm basically trying to accomplish what happens with Ruby's Capybara gem's save_and_open_page function within my React tests. Is it possible?
You can render a component in the browser by using the testing playground:
import { screen } from "@testing-library/react"
render(<MyComponent />)
// log entire document to testing-playground
screen.logTestingPlaygroundURL()
// log a single element
screen.logTestingPlaygroundURL(screen.getByText('test'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With