Skip to content

Files

Latest commit

 

History

History
28 lines (20 loc) · 571 Bytes

no-import-node-test.md

File metadata and controls

28 lines (20 loc) · 571 Bytes

Pattern: Import of node:test instead of vitest

Issue: -

Description

Importing from node:test instead of vitest can lead to inconsistent test results and missing features. Using vitest ensures compatibility and access to all testing functionality.

Examples

Example of incorrect code:

import { test } from "node:test";
import { expect } from "vitest";

test("foo", () => {
  expect(1).toBe(1);
});

Example of correct code:

import { test, expect } from "vitest";

test("foo", () => {
  expect(1).toBe(1);
});