• Error
  • Reported by the type checker

TS2593

Cannot find name '{0}'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.

A test runner global such as describe or it isn't known. Install your test runner's type definitions and add them to types.

What it means

The name is a global that test runners define (describe, it, test and similar), and no type definitions for one are loaded.

Example

index.ts
describe("math", () => {});
export {};
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(1,1): error TS2593: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types/jest` or `npm i --save-dev @types/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.

Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.

How to fix

  • Install the types for your runner, for example npm i --save-dev @types/jest or @types/mocha, and add it to types if tsconfig.json sets that option.
  • With runners that export these functions (Vitest, node:test), import them: import { describe, it } from "vitest".