JavaScript & TypeScript / Quiz
Typing the Test File
Why describe() is red in your editor, what @types/jest and vitest/globals actually do, and who type-checks your tests (spoiler: maybe nobody).
- Difficulty
- Easy
- Format
- Quiz
- Points
- 100
- Estimate
- 8 min
// MISSION BRIEF
Your Mission
A TypeScript test file has two masters: the test runner that executes it and the compiler that judges it. Configure only one and you get red squiggles on green tests, or worse, green tests on broken types.
This quiz covers wiring TypeScript into Jest and Vitest: ambient globals, the types array, what transforms your code, and which tool (if any) is actually checking types.
Speed bonus active.
// FIRST CONTACT
Battle teaser
Jest runs your .test.ts files fine, but the editor marks describe and expect as 'cannot find name'. The standard fix:
- AInstall @types/jest (or import from @jest/globals) so TypeScript learns the ambient test globals
- BSet strict: false in tsconfig
- CRename the files to .test.js
- DAdd // @ts-nocheck to every test file
Answers, scoring, hints, and the full battle stay sealed.
// SKILL TAGS
typescriptjestvitesttoolingunit-testing