1 | # Random data generator
|
2 |
|
3 |
|
4 |
|
5 | [![Build Status](https://img.shields.io/travis/com/travi/any.svg)](https://travis-ci.com/travi/any)
|
6 | [![Coverage Status](http://img.shields.io/coveralls/travi/any.svg)](https://coveralls.io/r/travi/any?branch=master)
|
7 |
|
8 |
|
9 |
|
10 | Random data generator for when test data is insignificant. Tailoring data too
|
11 | closely for the domain can end up being confusing in tests because it distracts
|
12 | from the behavior that is actually important in the test. This is why I prefer
|
13 | to make it very clear when test data is insignificant by using a data generator.
|
14 | This library captures most of the patterns I use frequently.
|
15 |
|
16 | ## Based on Chance.js
|
17 |
|
18 | To save myself from needing to maintain the actual data generators, this library
|
19 | leverages [Chance.js](http://chancejs.com/) for generating the data. So why not
|
20 | just use Chance.js directly?
|
21 |
|
22 | * I find it annoying that an instance of Chance has to be created. Rather than
|
23 | initialize an instance in every module, I wrap a single instance for reuse
|
24 | throughout the tests.
|
25 | * I can set my default options to align with my typical conventions rather than
|
26 | having to repeatedly configure Chance.js's very flexible API
|
27 | * Lots of my tests need objects to be generated, but the structure of those
|
28 | objects typically does not matter. Chance.js does not have a
|
29 | [simple-object generator](docs/API.md#simpleobject), so I've included that on
|
30 | my own.
|
31 | * Many of my tests need [lists](docs/API.md#listof) generated. Like objects,
|
32 | Chance.js does not generate lists, so I've included this on my own.
|
33 |
|
34 | ## Usage
|
35 |
|
36 |
|
37 |
|
38 | [![npm](https://img.shields.io/npm/v/@travi/any.svg?style=flat)](https://www.npmjs.com/package/@travi/any)
|
39 | [![monthly downloads](https://img.shields.io/npm/dm/@travi/any.svg?style=flat)](https://www.npmjs.com/package/@travi/any)
|
40 | [![license](https://img.shields.io/github/license/travi/any.svg?style=flat)](LICENSE)
|
41 | [![Try @travi/any on RunKit](https://badge.runkitcdn.com/@travi/any.svg)](https://npm.runkit.com/@travi/any)
|
42 |
|
43 |
|
44 |
|
45 | ### Install
|
46 |
|
47 | ```sh
|
48 | $ npm install @travi/any --save-dev
|
49 | ```
|
50 |
|
51 | ### Documentation
|
52 |
|
53 | * [API](docs/API.md)
|
54 | * [Debugging](docs/DEBUG.md)
|
55 |
|
56 | ## Contributing
|
57 |
|
58 |
|
59 |
|
60 | [![PRs Welcome][prs-badge]][prs]
|
61 | [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
|
62 | [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
|
63 | [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
|
64 | [![Renovate][renovate-badge]][renovate-link]
|
65 |
|
66 |
|
67 |
|
68 | ### Dependencies
|
69 |
|
70 | ```sh
|
71 | $ nvm install
|
72 | $ npm install
|
73 | ```
|
74 |
|
75 | ### Verification
|
76 |
|
77 | ```sh
|
78 | $ npm test
|
79 | ```
|
80 |
|
81 | [prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg
|
82 |
|
83 | [prs]: http://makeapullrequest.com
|
84 |
|
85 | [renovate-link]: https://renovatebot.com
|
86 |
|
87 | [renovate-badge]: https://img.shields.io/badge/renovate-enabled-brightgreen.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzNjkgMzY5Ij48Y2lyY2xlIGN4PSIxODkuOSIgY3k9IjE5MC4yIiByPSIxODQuNSIgZmlsbD0iI2ZmZTQyZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTUgLTYpIi8+PHBhdGggZmlsbD0iIzhiYjViNSIgZD0iTTI1MSAyNTZsLTM4LTM4YTE3IDE3IDAgMDEwLTI0bDU2LTU2YzItMiAyLTYgMC03bC0yMC0yMWE1IDUgMCAwMC03IDBsLTEzIDEyLTktOCAxMy0xM2ExNyAxNyAwIDAxMjQgMGwyMSAyMWM3IDcg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