Complete the code to import the testing function from Svelte Testing Library.
import { [1] } from '@testing-library/svelte';
The render function is used to render Svelte components in tests.
Complete the code to check if the component shows the text 'Hello World'.
expect(getByText([1])).toBeInTheDocument();The exact text 'Hello World' must be matched to find the element.
Fix the error in the test by completing the assertion to check the button is enabled.
expect(button).[1].toBeDisabled();toBe which expects a value, not a matcher.toHaveAttribute without specifying attribute.The not modifier with toBeDisabled() checks that the button is enabled (not disabled).
Fill both blanks to create a test that checks if clicking the button calls the mock function.
const mockFn = vi.fn();
const { getByRole } = render(Component, { props: { onClick: [1] } });
const button = getByRole('button');
button.[2]();
expect(mockFn).toHaveBeenCalled();fireEvent directly on the button instead of click().The mock function mockFn is passed as the click handler, and click() simulates the button click.
Fill all three blanks to write a test that renders a component, updates a prop, and checks the updated text.
const { getByText, component } = render(Component, { props: { message: [1] } });
expect(getByText([2])).toBeInTheDocument();
component.$set({ message: [3] });
expect(getByText('Updated')).toBeInTheDocument();$set.The component starts with message 'Initial', which is checked, then updated to 'Updated' and checked again.