vitest-sveltekit-bad-error-report Svelte Themes

Vitest Sveltekit Bad Error Report

Demo to show a bug in vitest error reporting in sveltekit

Bug when reporting errors

Reproduce errors

This repo shows a vitest bug when reporting errors in sveltekit projects. Just run:

$ npm run test:unit:server

and you will see:

 FAIL   server  src/lib/buggytest.test.ts > Show that error reporting is buggy > See that my error location/backtrace is plain wrong (and always the same)
Error: I AM HERE
 ❯ myBuggyFunction src/lib/buggytest.svelte.ts:24:8
     22|
     23| export function Iamnotevencalledyousee() {
     24|   let a = 1
       |        ^
     25|   a = a + 1
     26|   a = a + 1
 ❯ src/lib/buggytest.test.ts:8:12

See that the error is reported in Iamnotevencalledyousee that is not even called!

Creating a project

To recreate this project with the same configuration:

# recreate this project
npx [email protected] create --template minimal --types ts --add prettier eslint vitest="usages:unit" tailwindcss="plugins:none" --install npm demo

and add the two files in src/lib/buggytest.*.

Top categories

Loading Svelte Themes