Gathering detailed insights and metrics for tstyche
Gathering detailed insights and metrics for tstyche
Gathering detailed insights and metrics for tstyche
Gathering detailed insights and metrics for tstyche
npm install tstyche
Typescript
Module System
Min. Node Version
TypeScript (50.03%)
JavaScript (49.85%)
Shell (0.12%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
206 Stars
1,631 Commits
8 Forks
4 Watchers
6 Branches
3 Contributors
Updated on Jul 14, 2025
Latest Version
4.1.0
Package Id
tstyche@4.1.0
Unpacked Size
257.84 kB
Size
44.97 kB
File Count
10
Published on
Jun 26, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
Everything You Need for Type Testing.
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 isSameLength<T extends { length: number }>(a: T, b: T) { 4 return a.length === b.length; 5} 6 7test("isSameLength", () => { 8 expect(isSameLength([1, 2], [1, 2, 3])).type.toBe<boolean>(); 9 expect(isSameLength("one", "two")).type.toBe<boolean>(); 10 11 expect(isSameLength).type.not.toBeCallableWith(1, 2); 12});
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 unit tests:
1import assert from "node:assert";
2import test from "node:test";
3import * as tstyche from "tstyche";
4
5function toMilliseconds(value: number) {
6 if (typeof value === "number" && !Number.isNaN(value)) {
7 return value * 1000;
8 }
9
10 throw new Error("Not a number");
11}
12
13test("toMilliseconds", () => {
14 const sample = toMilliseconds(10);
15
16 assert.equal(sample, 10_000);
17 tstyche.expect(sample).type.toBe<number>();
18
19 // Will pass as a type test and not throw at runtime
20 tstyche.expect(toMilliseconds).type.not.toBeCallableWith("20");
21});
Here is the list of all matchers:
.toBe()
, .toBeAssignableTo()
, .toBeAssignableWith()
compare types or types of expression,.toAcceptProps()
checks the type of JSX component props,.toBeApplicable
ensures that the decorator function can be applied,.toBeCallableWith()
checks whether a function is callable with the given arguments,.toBeConstructableWith()
checks whether a class is constructable with the given arguments,.toHaveProperty()
looks up keys on an object type.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 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.