Gathering detailed insights and metrics for tstyche
Gathering detailed insights and metrics for tstyche
npm install tstyche
Typescript
Module System
Min. Node Version
JavaScript (51.35%)
TypeScript (48.49%)
Shell (0.16%)
Total Downloads
177,617
Last Day
430
Last Week
4,485
Last Month
15,094
Last Year
171,990
91 Stars
1,264 Commits
7 Forks
4 Watching
4 Branches
3 Contributors
Minified
Minified + Gzipped
Latest Version
3.5.0
Package Id
tstyche@3.5.0
Unpacked Size
232.85 kB
Size
41.30 kB
File Count
10
Publised On
14 Jan 2025
Cumulative downloads
Total Downloads
Last day
119.4%
430
Compared to previous day
Last week
80.4%
4,485
Compared to previous week
Last month
53.3%
15,094
Compared to previous month
Last year
2,956.5%
171,990
Compared to previous year
The Essential Type Testing Tool.
TSTyche is a type testing tool for TypeScript. It ships with describe()
and test()
helpers, expect
style assertions and a mighty test runner.
If you are used to test JavaScript, a simple type test file should look familiar:
1import { expect, test } from "tstyche"; 2 3function firstItem<T>(target: Array<T>): T | undefined { 4 return target[0]; 5} 6 7test("firstItem", () => { 8 expect(firstItem(["a", "b", "c"])).type.toBe<string | undefined>(); 9 10 expect(firstItem()).type.toRaiseError("Expected 1 argument"); 11});
To organize, debug and plan tests TSTyche has:
test()
, it()
and describe()
helpers,.only
, .skip
and .todo
run mode flags.The assertions can be used to write type tests (like in the above example) or mixed in your functional tests:
1import assert from "node:assert"; 2import test from "node:test"; 3import * as tstyche from "tstyche"; 4 5function secondItem<T>(target: Array<T>): T | undefined { 6 return target[1]; 7} 8 9test("handles numbers", () => { 10 assert.strictEqual(secondItem([1, 2, 3]), 2); 11 12 tstyche.expect(secondItem([1, 2, 3])).type.toBe<number | undefined>(); 13});
Here is the list of all matchers:
.toBe()
, .toBeAssignableTo()
, .toBeAssignableWith()
compare types or types of expression,.toAcceptProps()
checks JSX component props type,.toHaveProperty()
looks up keys on an object type,.toRaiseError()
captures the type error message or code,.toBeString()
, .toBeNumber()
, .toBeVoid()
and 9 more shorthand checks for primitive types.The tstyche
command is the heart of TSTyche. For example, it can select test files by path, filter tests by name and pass them through a range of TypeScript versions:
1tstyche query-params --only multiple --target '>=5.0 <5.3'
This simple! (And it has watch mode too.)
Visit https://tstyche.org to view the full documentation.
If you have any questions or suggestions, start a discussion or open an issue on GitHub. Preferring a chat? Join our Discord server.
MIT © TSTyche
No vulnerabilities found.
No security vulnerabilities found.