@@ -28,20 +28,20 @@ sidebar_label: Example
2828// NOTE: jest-dom adds handy assertions to Jest and it is recommended, but not required.
2929import ' @testing-library/jest-dom'
3030
31- import {render , fireEvent } from ' @testing-library/svelte'
31+ import {render , fireEvent , screen } from ' @testing-library/svelte'
3232
3333import Comp from ' ../Comp'
3434
3535test (' shows proper heading when rendered' , () => {
36- const { getByText } = render (Comp, {name: ' World' })
37-
38- expect (getByText ( ' Hello World! ' )) .toBeInTheDocument ()
36+ render (Comp, { name: ' World' })
37+ const heading = screen . getByText ( " Hello World! " );
38+ expect (heading) .toBeInTheDocument ();
3939})
4040
4141// Note: This is as an async test as we are using `fireEvent`
4242test (' changes button text on click' , async () => {
43- const { getByText } = render (Comp, {name: ' World' })
44- const button = getByText ( ' Button ' )
43+ render (Comp, { name: ' World' })
44+ const button = screen . getByRole ( " button " )
4545
4646 // Using await when firing events is unique to the svelte testing library because
4747 // we have to wait for the next `tick` so that Svelte flushes all pending state changes.
0 commit comments