Complete the code to import the Vitest test function.
import { [1] } from 'vitest';
The test function is imported from Vitest to define test cases.
Complete the code to assert that a value is true using Vitest.
import { test, expect } from 'vitest'; test('check true', () => { expect(true).[1](); });
toEqualTrue() which is not a Vitest matcher.toBeFalse() by mistake.The toBeTruthy() matcher checks if the value is truthy.
Fix the error in the Vitest config import statement.
import { defineConfig } from '[1]';
defineConfig from vitest or vite causes errors.svelte as import source here.The Vitest config helper defineConfig is imported from vitest/config.
Fill both blanks to create a Vitest config with Svelte plugin.
import { defineConfig } from 'vitest/config'; import [1] from '@sveltejs/vite-plugin-svelte'; export default defineConfig({ plugins: [[2]()] });
The Svelte plugin is imported as svelte and used as svelte() in plugins.
Fill all three blanks to write a basic Vitest test for a Svelte component.
import { test, expect } from 'vitest'; import [1] from './MyComponent.svelte'; import { render } from '@testing-library/svelte'; test('renders component', () => { const { [2] } = render([3]); expect(container).toBeTruthy(); });
We import the component as MyComponent, destructure container from render(MyComponent), then check if container exists.
