Registry / testing / test-mixer

test-mixer

JSON →
library4.2.3jsnpmunverified

test-mixer is a JavaScript/TypeScript utility library designed to assist with testing by programmatically generating variations of JavaScript option objects. Its primary function is to create all possible combinations of boolean properties within a given default options object, which is highly useful for comprehensive test coverage without manually listing every permutation. The current stable version is 4.2.3. The library allows users to "pin" specific option values, effectively reducing the number of combinations generated by fixing certain parameters while iterating through others. Unlike some other testing utilities, test-mixer focuses specifically on combinatorial generation of option objects, making it a specialized tool for ensuring robust test suites, particularly for functions that accept configuration objects with many boolean flags. It is distributed as a pure ESM package and requires Node.js >=14.18.0.

npm install test-mixer
INSTALL
IMPORT
SIG · TEST-MIXER
T
test-mixer
testingjavascriptv4.2.3
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

mixer
import { mixer } from 'test-mixer';
const { mixer } = require('test-mixer');
The 'mixer' function is the primary export. As of v3, test-mixer is a pure ESM package; CommonJS 'require' is not supported.
MixerOpts
import type { MixerOpts } from 'test-mixer';
Import the 'MixerOpts' type for type-checking when working with TypeScript, representing the shape of the options objects used by the mixer function.
mixer (default import, incorrect)
import { mixer } from 'test-mixer';
import mixer from 'test-mixer';
The 'mixer' function is a named export, not a default export. Attempting a default import will result in 'mixer is not a function' or similar runtime errors.

This quickstart demonstrates how to use the 'mixer' function to generate all boolean combinations of an options object and how to 'pin' specific values to reduce permutations, which is useful for targeted testing.

import { strict as assert } from "assert"; import { mixer } from "test-mixer"; // Define a default options object with various types, including booleans const defaultOpts = { scrapeWindshield: true, checkOil: true, inflateTires: false, extinguishersCount: 1, // Non-boolean, will be ignored for boolean combinations notes: "initial", }; // Generate all possible combinations of boolean options // The empty first argument object means generate combinations for all booleans const allCombinations = mixer({}, defaultOpts); // Expected output: 2^3 = 8 combinations (for scrapeWindshield, checkOil, inflateTires) assert.equal(allCombinations.length, 8); assert.deepEqual(allCombinations[0], { scrapeWindshield: false, checkOil: false, inflateTires: false, extinguishersCount: 1, notes: "initial" }); // Pin 'scrapeWindshield' to true and generate combinations for other booleans const pinnedCombinations = mixer({ scrapeWindshield: true }, defaultOpts); // Expected output: 2^(3-1) = 4 combinations assert.equal(pinnedCombinations.length, 4); assert.ok(pinnedCombinations.every(opts => opts.scrapeWindshield === true)); assert.deepEqual(pinnedCombinations[0], { scrapeWindshield: true, checkOil: false, inflateTires: false, extinguishersCount: 1, notes: "initial" });
Debug
Known issues
breakingtest-mixer transitioned to being a pure ES Module (ESM) package starting from version 3.x. This means it can no longer be imported using CommonJS 'require()' statements.
fix
Migrate your project to use ES module syntax (e.g., `import { mixer } from 'test-mixer';`). If unable to migrate, install an older version like `test-mixer@2.1.0`.
affects: >=3.0.0
gotchaThe 'mixer' function primarily generates variations for boolean properties within the options object. Non-boolean properties (e.g., numbers, strings, objects) are copied as-is from the `defaultOpts` and do not participate in the combinatorial generation.
fix
Ensure that the properties you intend to vary combinatorially are booleans. For non-boolean variations, manual iteration or other specialized libraries might be required.
affects: >=1.0.0
breakingNode.js v14.18.0 or newer is required due to the package being pure ESM. Older Node.js versions may not correctly resolve or execute the module.
fix
Update your Node.js environment to version 14.18.0 or higher. For projects constrained to older Node.js versions, consider using `test-mixer@2.1.0`.
affects: >=3.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module ...test-mixer.js not supported.
Attempting to import `test-mixer` using CommonJS `require()` syntax in a Node.js environment, but the package is pure ESM.
fix
Change your import statement from `const { mixer } = require('test-mixer');` to `import { mixer } from 'test-mixer';` and ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`).
TypeError: mixer is not a function
This usually occurs when attempting to use a default import for `mixer` (e.g., `import mixer from 'test-mixer';`) or when `require()` is used on a mixed CommonJS/ESM setup incorrectly.
fix
Ensure you are using a named import: `import { mixer } from 'test-mixer';`. If using TypeScript, confirm your `tsconfig.json` compiler options (e.g., `"module": "esnext"`, `"esModuleInterop": true`) are correctly configured.
Upgrade
Version history
4.2.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Resources