tinyexpect
v0.5.1
Published
`expect` is a lightweight testing utility with 0 dependencies that provides a Jest-like assertion API for TypeScript/JavaScript projects that use the native Node.js test runner `node --test`.
Readme
tinyexpect
expect is a lightweight testing utility with 0 dependencies that provides a Jest-like assertion API for TypeScript/JavaScript projects that use the native Node.js test runner node --test.
API Reference
Matchers
toBe(value): Checks strict equality (including deep equality for objects)toNotBe(value): Checks strict inequalityeitherOr(values[]): Checks if value is included in an array of possible valuestoBeNumber(): Verifies value is a numbertoBeNumberOrParsed(): Verifies value is either a number or can be parsed as onetoBeNumberOr(values[]): Verifies value is either a number or one of the specified stringstoBeFalsy(): Checks if value is falsytoBeTruthy(): Checks if value is truthytoBeDefined(): Verifies value is not undefinedtoContainString(str): Checks if string contains a substringtoNotContainString(str): Checks if string does not contain a substring
Error Handling
All matchers throw descriptive errors when assertions fail, including:
- Detailed error messages for object comparisons
- Type mismatch notifications
- Clear expected vs actual value reporting
License
MIT
