Always use fourslash tests (for IDE/language service features) or compiler tests (for TypeScript compilation behavior) instead of direct unit tests. Place tests in the correct directories: `tests/cases/compiler` or `tests/cases/fourslash`.
Always use fourslash tests (for IDE/language service features) or compiler tests (for TypeScript compilation behavior) instead of direct unit tests. Place tests in the correct directories: tests/cases/compiler
or tests/cases/fourslash
.
Fourslash tests validate IDE features like completions and refactoring:
/// <reference path='fourslash.ts'/>
//// interface User {
//// name: string;
//// }
////
//// const user: User = {
//// /*completion*/
//// };
verify.completions({
marker: "completion",
includes: { name: "name" }
});
Compiler tests validate TypeScript type checking:
// @Filename: test.ts
// @strict: true
interface Config {
required: string;
optional?: number;
}
const config1: Config = { required: "test" }; // Should work
const config2: Config = { optional: 42 }; // Should error - missing required
When adding tests, ensure you run them individually first with hereby runtests --tests=path/to/test.ts
to verify they demonstrate the expected behavior correctly before committing.
Enter the URL of a public GitHub repository