Vitest report an error with assertType<string>
Version: Deno 2.5.6
I run Deno test with Vitest library and want to test assertType<string>
Is it due to Deno or Vitest ?
assertType
PoC in zip deno-vitest.zip
./add/index.test.ts (uncaught error)
error: (in promise) Error: Vitest failed to find the current suite. This is a bug in Vitest. Please, open an issue with reproduction.
at assert
at getCurrentSuite
at Object.<anonymous>
at chain
This error was not caught from a test and caused the test runner to fail on the referenced module.
It most likely originated from a dangling promise, event/timeout handler or top-level code.
Can you please provide a repro as a repository instead of zip archive?
here the project https://github.com/foobar-maker/deno-vitest
Looks like vitest calls tsc under the hood which bypasses the instance that ships with Deno:
https://github.com/vitest-dev/vitest/blob/67a39f5e3973f44bb62dd071b44106fe4e3beb13/packages/vitest/src/typecheck/typechecker.ts#L262-L310
@marvinhagemeister how is that a bug then?
Upon closer inspection it turns out that this particular error doesn't seem to be related to the type checking capabilities in vitest. It fails without these too. I've filed an upstream issue https://github.com/vitest-dev/vitest/issues/9170
Well, we missed a crucial detail: The test task doesn't run vitest, it runs deno test. And then vitest rightfully complains that all the test suite detection is missing, simply because vitest wasn't run.
The fix:
"tasks": {
- "test": "deno test --allow-env",
+ "test": "vitest"
},