Complete the code to import the Svelte testing library function needed to render a component.
import { [1] } from '@testing-library/svelte';
The render function from '@testing-library/svelte' is used to render Svelte components in tests.
Complete the code to check if a button with text 'Click me' is in the document after rendering.
const { getByText } = render(Component);
expect(getByText('[1]')).toBeInTheDocument();The test checks for a button with the exact text 'Click me' to confirm it appears in the rendered component.
Fix the error in the test by completing the code to simulate a click event on the button.
const { getByText } = render(Component);
const button = getByText('Click me');
[1](button);To simulate a user clicking the button, use fireEvent.click on the button element.
Fill both blanks to import the event helper and simulate a click on a button.
import { render, [1] } from '@testing-library/svelte'; const { getByText } = render(Component); [2](getByText('Click me'));
You import fireEvent and then call fireEvent.click to simulate clicking the button.
Fill all three blanks to write a test that renders a component, clicks a button, and checks if a message appears.
import { render, [1] } from '@testing-library/svelte'; test('shows message on click', async () => { const { getByText, queryByText } = render(Component); expect(queryByText('Hello!')).toBeNull(); await [2](getByText('Click me')); expect(getByText('[3]')).toBeInTheDocument(); });
This test imports fireEvent, clicks the button with fireEvent.click, and then checks that the message 'Hello!' appears.