foobarF
Deno2mo ago
1 reply
foobar

Testing a Deno project with Vitest

Is it possible ?
I have a monorepo mixing Deno & Node package. I wanted to use only a single testing library like Vitest

If we use vitest as a runner : can't resolve Deno import style like import { generate } from "@std/uuid/unstable-v7";
if we use vitest as a library : error see issue https://github.com/denoland/deno/issues/31302

Has someone already use Vitest in project ?

index.ts
import { generate } from "@std/uuid/unstable-v7";

export const uuid = (): string => {
  return generate();
};


test
import { assertType, test } from "vitest";
import { uuid } from "./index.ts";

test("uuid", () => {
  assertType<string>(uuid());
});


deno.json
{
  "name": "@foobar/deno-vitest",
  "exports": {
    "./index.ts": "./index.ts",
  },
  "imports": {
    "@std/uuid": "jsr:@std/uuid@^1.0",
    "vitest": "npm:vitest",
  },
  "tasks": {
    "test": "deno run -A --node-modules-dir npm:vitest",
  },
}
GitHub
Version: Deno 2.5.6 I run Deno test with Vitest library and want to test assertType&lt;string&gt; Is it due to Deno or Vitest ? assertType(&quot;aaa&quot;) =&gt; works assertType(uuid()) =&gt; erro...
Vitest report an error with assertType<string> · Issue #31302 · d...
Was this page helpful?