doctest-ts/README.md

33 lines
891 B
Markdown

# doctest-ts-improved: doctests for TypeScript
Easy doctests for typescript modules, including private methods and extra imports:
```
export default class SomeClass {
/**
* Gets the field doubled
* @example xyz
*
* import OtherClass from "./OtherClass";
*
* // Should equal 42
* SomeClass.get() // => 42
*
* SomeClass.get() + 1 // => 43
*
* new OtherClass().doSomething(new SomeClass()) // => 5
*/
private static get() : number{
// a comment
// @ts-ignore
return 42
}
}
```
Running `doctest-ts-improved <directory>` will create a copy of all `.ts`-files, containing the runner code. The new files will be named `<original-filename>.doctest.ts`.
To ignore a (group of) files, add `--ignore filename.ts` or `--ignore <directory>/*.ts`. Multiple `--ignore`-flags can be given.
# License
MIT