How to test SvelteKit app with Jest

5 min readOct 9, 2021

One of my weaknesses is the lack of discipline when it comes to testing. So I started looking around and figuring out how to do it. There are many frameworks, and frankly I am too ignorant on the subject to decide which one to use. As a result I went absolutely random and decided to use Jest. I decided to use Jest with SvelteKit. These are my notes.

Create a new project

Unlike the last posts, today I start with a completely new project. I don’t want to deal with old code while learning something new. I create a new SvelteKit based project using the command:

npm init svelte@next

I use these settings:

Which Svelte app template? » Skeleton project
Use TypeScript? » Yes
Add ESLint for code linting? » Yes
Add Prettier for code formatting? » Yes

Then I install the dependencies:

npm install

I check that everything is successful by launching:

npm run dev -- --open

Good. So far the easy part. Now the fun begins.

Install Jest

As always, I searched the internet. There are many interesting posts

I have used many of the tips in these guides to understand how to make my project work.

As recommended in a simple and effective way by Dave Ceddia I need some packages:

How To Interact With Google Chart

5 min read

Feb 10, 2022

Visualize Your Medium Stats With Svelte and JavaScript

7 min read

Jan 25, 2022

How to Get Medium Stats With JavaScript and Svelte

6 min read

Jan 17, 2022

How To Create Responsive Data Tables With CSS Grid

8 min read

Jan 12, 2022

How to Get Medium Stats With JavaScript and Svelte

6 min read

Jan 8, 2022

How To Document Svelte Components — Part 2

5 min read

Jan 2, 2022

The Journey of a Novice Programmer

8 min read

Dec 12, 2021

How to Create an Accordion Element With Svelte and Tailwind

4 min read

Nov 28, 2021

How to Test If a Dom Element Exists in a Svelte Component with Jest

2 min read

Nov 17, 2021

How to Document Svelte Components

5 min read

Nov 15, 2021


I'm a hobby programmer, experimenting with Svelte, Javascript, Construct 3 and magic tools