Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
tstyche
Advanced tools
Changelog
Readme
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:
import { expect, test } from "tstyche";
function firstItem<T>(target: Array<T>): T | undefined {
return target[0];
}
test("firstItem", () => {
expect(firstItem(["a", "b", "c"])).type.toEqual<string | undefined>();
expect(firstItem()).type.toRaiseError("Expected 1 argument");
});
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:
import assert from "node:assert/strict";
import { test } from "node:test";
import * as tstyche from "tstyche";
function secondItem<T>(target: Array<T>): T | undefined {
return target[1];
}
test("handles numbers", () => {
assert.strictEqual(secondItem([1, 2, 3]), 2);
tstyche.expect(secondItem([1, 2, 3])).type.toEqual<number | undefined>();
});
Here is the list of all matchers:
.toBeAssignable()
, .toEqual()
, .toMatch()
compares types or types of expression,.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 TypeScript 4.8
and latest
:
tstyche JsonObject --only external --target 4.8,latest
This simple!
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
FAQs
The Essential Type Testing Tool.
The npm package tstyche receives a total of 2,334 weekly downloads. As such, tstyche popularity was classified as popular.
We found that tstyche demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.