Trapit (v1.0.24) is a JavaScript module implementing The Math Function Unit Testing Design Pattern. It provides a data-driven approach to unit testing where test inputs and expected outputs are specified in JSON, leading to reusable scenarios. Key features include: multi-scenario testing, formatted output as plain text or HTML, support for external programs via JSON results file, and avoidance of microtesting. It is designed for transactional units and supports refactoring. The module has a stable release cadence (last update years ago) and differs from traditional frameworks like Jest or Mocha by emphasizing declarative test data and full scenario coverage according to the SCAN method.
npm install trapitNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates using Trapit to run data-driven tests from a JSON scenarios file and format results as text and HTML.
Wrap async functions to return promises synchronously or restructure to use callbacks.
Consider using 'text' output or custom formatting; HTML output is deprecated.
Ensure all test inputs/outputs are plain objects/arrays; avoid functions, Symbols, or circular references.
Use precise expected values; for complex comparisons, pre-process outputs in test function.
Consider other testing frameworks like Jest, Mocha, or Vitest for active support.
npm install trapit --save-dev
import { runTest } from 'trapit';Convert expected and actual values to JSON-serializable formats.
No dependency data recorded yet.