Registry / testing / test-helpr

test-helpr

JSON →
library0.3.2jsnpmunverified

A collection of miscellaneous test helper functions for Node.js, version 0.3.2. Provides lightweight utilities to simplify common testing patterns. The package is minimal and has no dependencies, making it easy to integrate. It is released sporadically, with no active development since 2020. Differentiators include simplicity and zero external dependencies compared to larger testing libraries like Jest or Mocha.

npm install test-helpr
INSTALL
IMPORT
SIG · TEST-HELPR
T
test-helpr
testingjavascriptv0.3.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createMockContext
✓ import { createMockContext } from 'test-helpr'
✗ const createMockContext = require('test-helpr')
ESM-only since v0.3.0
mockFn
✓ import { mockFn } from 'test-helpr'
✗ import mockFn from 'test-helpr'
Not a default export; must use named import.
stubConsole
✓ import { stubConsole } from 'test-helpr'
✗ const { stubConsole } = require('test-helpr')
Use ESM import in modern Node.js (>=12).

Demonstrates importing and using three main helpers: createMockContext, mockFn, and stubConsole.

import { createMockContext, mockFn, stubConsole } from 'test-helpr'; // Create a mock context const ctx = createMockContext(); // Create a mock function const mock = mockFn(); mock('arg'); console.log(mock.calls); // [['arg']] // Stub console.log const restore = stubConsole(); console.log('test'); console.log(console.output); // ['test'] restore();
Debug
Known issues
breakingESM-only since version 0.3.0; CommonJS require() no longer supported.
fix
Use import syntax: import { ... } from 'test-helpr'
affects: >=0.3.0
deprecatedFunctions may have undocumented side effects; no active maintenance.
fix
Consider migrating to a more actively maintained library like sinon.
affects: <=0.3.2
gotchamockFn does not reset calls between test cases; manual reset needed.
fix
Reset mock.calls = [] in beforeEach or afterEach.
affects: <=0.3.2
Errors
Common errors & fixes
Cannot find module 'test-helpr'
Package not installed or ESM-only require attempt.
fix
Run npm install test-helpr and use import syntax.
The requested module 'test-helpr' does not provide an export named 'default'
Trying to default import from a package that only has named exports.
fix
Use import { ... } from 'test-helpr' instead of import testHelpr from 'test-helpr'.
Error: Cannot find module 'test-helpr' require() of ES Module
Using require() with an ESM-only package.
fix
Replace require() with import, or use dynamic import() if necessary.
Upgrade
Version history
0.3.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
test-helpr — npm install test-helpr · libregistry