https://github.com/thiagodp/one-wise
One-wise combinatorial testing generator for JavaScript
https://github.com/thiagodp/one-wise
combinatorial-testing javascript n-way n-wise one-wise pair-wise pairwise seedrandom shuffle testing
Last synced: 25 days ago
JSON representation
One-wise combinatorial testing generator for JavaScript
- Host: GitHub
- URL: https://github.com/thiagodp/one-wise
- Owner: thiagodp
- License: mit
- Created: 2018-03-27T02:38:47.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-07-05T00:55:51.000Z (almost 5 years ago)
- Last Synced: 2025-03-18T10:51:57.281Z (about 2 months ago)
- Topics: combinatorial-testing, javascript, n-way, n-wise, one-wise, pair-wise, pairwise, seedrandom, shuffle, testing
- Language: JavaScript
- Homepage:
- Size: 187 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# one-wise
> One-wise combinatorial testing generator
[](https://badge.fury.io/js/one-wise)
[](https://travis-ci.org/thiagodp/one-wise)
[](https://coveralls.io/github/thiagodp/one-wise)A **1-wise** (*a.k.a.* **1-way**) testing generator guarantees that at least one value of each group appears in the generated tests. The produced array has exactly the length of the largest input array.
## About
This is a fast and simple implementation of a [1-wise testing](https://en.wikipedia.org/wiki/All-pairs_testing) generator. No external dependencies. Uses [semantic versioning](https://semver.org/).
## Install
```bash
npm install one-wise
```## Example
```javascript
oneWise( {
"foo": [ "x", "y" ],
"bar": [ "a", "b", "c", "d" ],
"baz": [ "f", "g" ]
} )
```
will return
```json
[
{ "foo": "x", "bar": "a", "baz": "f" },
{ "foo": "y", "bar": "b", "baz": "g" },
{ "foo": "x", "bar": "c", "baz": "f" },
{ "foo": "y", "bar": "d", "baz": "g" }
]
```
**Note**: the values of `foo` and `bar` in the last two lines are picked *randomly*.It uses JavaScript's `Math.random()`, but a *predictive* pseudo-random generator function (*e.g.,* [seedrandom](https://github.com/davidbau/seedrandom)) can be passed as a second argument. Such function must work like `Math.random()` and return a number >= 0 and < 1.
```javascript
oneWise( /* your object */, myPseudoRandomNumberGenerator );
```## Declaration
### Browser
```html
console.log(
oneWise( {
"foo": [ "x", "y" ],
"bar": [ 1, 2, 3 ]
} )
);```
**Option 2**: Using unpkg and ESM:
```htmlimport oneWise from 'one-wise';
```
### CommonJS (NodeJS)
```javascript
const oneWise = require('one-wise');
```### ESM/TypeScript
```javascript
import oneWise from 'one-wise';
```## API
### oneWise( obj [, prngFunc ] )
- `obj` {object} - The given object.
- `prngFunc` {function} - Pseudo-random number generator function used to pick array elements to repeat. Defaults to `Math.random`.## See also
- [shuffle-obj-arrays](https://github.com/thiagodp/shuffle-obj-arrays) - Shuffles the arrays of the given object. A custom PRNG can be used.
- [seedrandom](https://github.com/davidbau/seedrandom) - Predictive PRNG## License
[MIT](LICENSE) © [Thiago Delgado Pinto](https://github.com/thiagodp)