sindresorhus/test-extras — explained in plain English
Analysis updated 2026-05-18
Write tests with a throws assertion that returns the caught error for further checks.
Use asymmetric matchers to check that an object or array has a certain shape without an exact match.
Add missing checks like isEmpty, inRange, or sameMembers to a plain node:test or Vitest suite.
Replace ad-hoc custom assertion helpers with a single small dependency.
| sindresorhus/test-extras | ajaxfnc-yt/d.w.i.f | alanhuang168/ai-project-workflow | |
|---|---|---|---|
| Stars | 17 | 17 | 17 |
| Language | JavaScript | JavaScript | JavaScript |
| Setup difficulty | easy | moderate | easy |
| Complexity | 1/5 | 2/5 | 3/5 |
| Audience | developer | developer | developer |
Figures from each repo's GitHub metadata at analysis time.
Install with npm as a dev dependency and import the specific functions you need.
test-extras is a small helper library for writing tests in JavaScript or TypeScript. Node's own built in assert module is deliberately basic, and this package fills in the gaps with the kind of assertions people are used to from testing frameworks like AVA and Jest, such as a throws check that actually hands you back the error it caught so you can inspect it further. Every function in the package is a plain standalone function that raises an AssertionError when a check fails, so it is not tied to any particular test runner. It works equally well inside node:test, Vitest, or even a plain script with no test runner at all, and it does not modify or depend on any of them. You install it as a development dependency with npm, then import only the specific assertions or matchers you need. The library covers a wide range of situations: catching thrown errors and rejected promises while returning the error itself, checking numeric closeness for floating point comparisons, checking whether a collection includes or excludes a value, checking a value is one of several allowed options, comparing arrays regardless of order, checking types with instanceOf, and checking whether something is empty. It also provides asymmetric matchers, a way of checking that a value matches a shape or type rather than an exact value. These matchers, such as any type checks, objectContaining for partial object matching, arrayContaining for partial array matching, and stringMatching for pattern based string checks, are used inside a matches function and can be nested inside each other to build flexible checks on objects and arrays. Overall this is a lightweight testing utility aimed at developers who want richer, more expressive assertions than Node's built in assert module offers, without committing to a full alternate testing framework.
A lightweight assertion library that adds richer test checks, like error-returning throws and shape-based matchers, on top of Node's basic assert module.
Mainly JavaScript. The stack also includes JavaScript, Node.js, TypeScript.
Setup difficulty is rated easy, with roughly 5min to a first successful run.
Mainly developer.
This repo across BitVibe Labs
Don't trust strangers blindly. Verify against the repo.