- 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
describe("math", () => {});
export {};
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.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/jestor@types/mocha, and add it totypesiftsconfig.jsonsets that option. - With runners that export these functions (Vitest,
node:test), import them:import { describe, it } from "vitest".