Unroll is a JavaScript helper library designed to simplify parameterized testing across both browser and Node.js environments. Currently at version 1.6.0, it allows developers to run a single test function against multiple sets of data, drawing inspiration from the 'Unroll annotation' found in the Spock framework for Java. It offers a structured way to define test data, either through an array of arrays or using a multiline template literal, enhancing test clarity and reducing redundancy. Unroll functions by decorating the primary test function (e.g., `it` in Mocha/Jasmine, `test` in AVA/Tape) of various testing frameworks, making it highly adaptable. The library's release cadence is intermittent, driven by bug fixes and minor feature enhancements, with its latest stable release focusing on improving argument handling and overall robustness. Its core value proposition lies in providing a framework-agnostic solution for data-driven tests, enabling detailed output for each test iteration.
npm install unrollVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to integrate `unroll` with a testing framework (mocked `it` function), define parameterized tests using template literals, and access parameters via the `testArgs` object. It also highlights the need for `JSON.stringify` for complex types in template literals.
Use `${JSON.stringify(yourObject)}` or `${JSON.stringify(yourArray)}` within the template literal data table.Ensure `unroll.use(yourTestFunction);` is executed early in your test setup, typically at the top of your test file or a setup hook.
Rewrite test functions to accept `testArgs` as the second parameter (after `done`) and access values like `testArgs['yourParam']`.
Upgrade to `unroll` version 1.2.1 or newer to ensure correct argument reuse behavior.
Ensure `unroll.use(it);` (or your test function) is called once before any `unroll()` invocations.
Modify the test function signature to `function(done, testArgs)` and access parameters as `testArgs['a']`, `testArgs['b']`, etc.
Wrap objects and arrays within the template literal with `JSON.stringify()`: `${JSON.stringify({ yourKey: 'value' })}`.No dependency data recorded yet.