mocha-froth/README.md

77 lines
2.2 KiB
Markdown
Raw Permalink Normal View History

2018-02-19 22:02:58 -07:00
# mocha-froth
2018-03-04 18:06:44 -07:00
2018-03-04 18:10:43 -07:00
[![npm version](https://badge.fury.io/js/mocha-froth.svg)](https://www.npmjs.com/package/mocha-froth)
2018-03-04 18:06:44 -07:00
[![Travis Build Status](https://travis-ci.org/keith24/mocha-froth.svg?branch=master)](https://travis-ci.org/keith24/mocha-froth)
2018-02-24 16:54:11 -07:00
[![Coverage Status](https://coveralls.io/repos/github/keith24/mocha-froth/badge.svg?branch=master)](https://coveralls.io/github/keith24/mocha-froth?branch=master)
2018-03-04 18:07:50 -07:00
[![Snyk Vulnerabilities](https://snyk.io/test/github/keith24/mocha-froth/badge.svg?targetFile=package.json)](https://snyk.io/test/github/keith24/mocha-froth?targetFile=package.json)
2018-02-23 15:33:44 -07:00
Fuzzer for mocha testing. Or any javascript testing suite, really. This package provides a function that returns an array of random strings. You know, a [fuzzer](https://en.wikipedia.org/wiki/Fuzzer).
2018-02-19 22:02:58 -07:00
2018-02-24 16:58:41 -07:00
2018-02-19 22:02:58 -07:00
## Installation
2018-02-23 12:11:20 -07:00
```sh
2018-03-04 18:13:51 -07:00
npm install --save-dev mocha-froth
2018-02-23 12:11:20 -07:00
```
2018-02-19 22:02:58 -07:00
## Usage
2018-02-23 12:11:20 -07:00
Import froth into your project
```javascript
const froth = require('mocha-froth')
```
Use the syntax `froth(num, max, opt)`where:
2018-02-23 13:49:54 -07:00
* *num* is the number of strings generated
* *max* is the maximum string length
* *opt* is an object of options for characters to include
2018-02-23 12:11:20 -07:00
```javascript
opt = {
2018-02-24 17:54:22 -07:00
// Set to true to include tests with...
none: true, // Empty string
whitespace: true, // Various whitespace chars
quotes: true, // Combinations of quotes
backslashing: true, // Combinations of backslashes
symbols: true, // Various symbols
foreign: true, // Foreign chars
alphanumeric: true, // Ordinary letters and numbers
2018-02-23 12:11:20 -07:00
}
```
2018-02-24 16:58:41 -07:00
mocha-froth will return an array of strings you can use to test your code.
2018-02-23 13:49:54 -07:00
### Examples
2018-02-23 12:11:20 -07:00
Create ten random strings, each up to twenty characters (default):
```javascript
console.log( froth() )
// [ '``8\\ёðNàЧ,', 'µ', '\\,нcy', '?O¬ìè¶ſ\r4á%"Е~', '', 'ИôAàяjùgzH%хйf', 'd\r\nïЧо', '«&pcj→ъгPfЬа|h', 'ñgMſииe&?“3ьXî¢òдq<ц', 'Un5tĸ' ]
```
Create five strings up to ten characters:
```javascript
console.log( froth(5,10) )
// [ '¢m\'\'\'ý7\'', 'óé€с-', 'фяþnЭOо', '', 'ykUбáФ¿ŷ¢С' ]
```
Same as above, but without foreign characters:
2018-02-24 16:58:41 -07:00
2018-02-23 12:11:20 -07:00
```javascript
console.log( froth(5,10,{foreign:false}) )
// [ 'VP"""t¬mK²', '²L6)>\r\nV', 'v,→“', '*e8', '→' ]
```
2018-02-23 15:29:33 -07:00
2018-02-24 16:58:41 -07:00
2018-02-23 15:29:33 -07:00
## Testing
```sh
npm test
```