0
0
Svelteframework~5 mins

Vitest setup in Svelte - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Anpm install -D vitest @testing-library/svelte @testing-library/jest-dom
Bnpm install vitest svelte
Cnpm install -g vitest
Dnpm install svelte-testing-library
Where do you configure Vitest settings in a SvelteKit project?
AIn a separate vitest.config.js file by default
BIn svelte.config.js
CIn package.json scripts only
DIn vite.config.js or vite.config.ts under the test property
What command runs Vitest tests from the terminal?
Anpx vitest
Bnpm start
Cnpm build
Dvitest run
Why use @testing-library/svelte with Vitest?
ATo compile Svelte components faster
BTo deploy Svelte apps
CTo render and interact with Svelte components in tests easily
DTo write CSS styles
Which file typically contains the test scripts for Vitest?
Astyle.css
BFiles with .test.js or .spec.js extensions
Cmain.js
Dindex.html
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.