Recall & Review
beginner
What is Vitest used for in a Svelte project?
Vitest is a testing framework used to write and run tests for your Svelte components and JavaScript code. It helps ensure your code works as expected.
Click to reveal answer
beginner
Which command installs Vitest and its related dependencies in a Svelte project?
You run
npm install -D vitest @testing-library/svelte @testing-library/jest-dom to install Vitest and testing libraries for Svelte.Click to reveal answer
intermediate
Where do you add the Vitest configuration in a SvelteKit project?
You add Vitest settings inside the
vite.config.js or vite.config.ts file under the test property to customize test behavior.Click to reveal answer
beginner
How do you run Vitest tests from the command line?
Use
npx vitest or add a script like "test": "vitest" in package.json and run npm test.Click to reveal answer
intermediate
Why is it important to include
@testing-library/svelte with Vitest?Because
@testing-library/svelte provides helpful tools to render Svelte components and interact with them in tests, making tests easier and more reliable.Click to reveal answer
Which command installs Vitest and testing libraries for Svelte?
✗ Incorrect
Option A installs Vitest and the recommended testing libraries for Svelte projects.
Where do you configure Vitest settings in a SvelteKit project?
✗ Incorrect
Vitest configuration is usually added inside vite.config.js or vite.config.ts under the test property.
What command runs Vitest tests from the terminal?
✗ Incorrect
You run tests with npx vitest or npm test if you set a script.
Why use @testing-library/svelte with Vitest?
✗ Incorrect
@testing-library/svelte helps test Svelte components by rendering and simulating user actions.
Which file typically contains the test scripts for Vitest?
✗ Incorrect
Test files usually have .test.js or .spec.js extensions so Vitest can find and run them.
Explain the steps to set up Vitest in a new Svelte project.
Think about installation, configuration, writing tests, and running them.
You got /4 concepts.
Describe why @testing-library/svelte is important when using Vitest.
Focus on how it helps interact with components during testing.
You got /4 concepts.