0.6.1 • Published 5 years ago

lib-monkey v0.6.1

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

lib-monkey

Travis Coveralls github David Dependency Status npm API Doc

Monkey Testing for libraries

When there is a need to test code with random values

Installation

  npm install lib-monkey

cli

  npm install -g lib-monkey


  lib-monkey -s [seed] [CMD]

  lib-monkey -j [joker description]

  
  # example

  lib-monkey -s 16012018 -j int.min(0).max(10) ===> 7

Getting Started

There are multiple jokers and runners to use for the library but the basic idea is to send the joker to one of the runners to know where to put the random value

const monkey = require('lib-monkey');

monkey
  .fnr
  .params(monkey.int.min(0).max(10))
  .register(a => {
      
      // Do some tests with a as ranom value
      // Will accept sync or prommise based results

  })
  .exec(n_times, concurrency)
  .then(() => { // Passed })
  .catch(err => { //There is an error })

monkey
  .fnr
  .params(monkey.int.min(0).max(10))
  .register((a, done) => {
      
      // Do some tests with a as ranom value

      // Call done after async tests

  })
  .exec(n_times, concurrency)
  .then(() => { // Passed })
  .catch(err => { //There is an error })

Jokers

There are multipe jokers in library and they have multiple modifyers.

There is the base modifyer nullable(boolean|chance|null == true) and all the other modifyers are based of of Chance library

Example

monkey.int.min(0).max(10) => chance.integer({ min:0, max: 10 })

monkey.bool.likelihood(70) => chance.bool({ likelihood: 70 })

Currently there are the following jokers:

  • bool, char, float, int, letter, natural, string
  • date, hammertime, timestamp, timezone
  • paragraph, sentence, syllable, word
  • pick (from array), array (of jokers), map, object (deep map), typed (of specific type)

Runners

Currently there are two runners avialbe, FunctionRunner - fnr and PipedRunner - pnr

FunctionRunner is designed to run a single function multipe times while the PipedRunner is designed to run several function and piping the result from one to the other

Example

  monkey
    .pnr
    .params(monkey.natural.max(10))
    .register(num => num + 1)
    .register(num => num + 1)
    .register(num => num + 1)
    .params(monkey.syllable)
    .register((num, randomSylibalValue) => console.log('Will be the original num + 3', num, randomSylibalValue))
    .exec(3)

Roadmap

This project should co-exist with all the avialbe test runners like mocha or jasmin and be used as a tool for random value testing

  • Add more Jokers and Runners
  • Add self assertion api
  • Finish the docs
  • Create code coverage for the library
  • Maybe change the api to be dot chainable

License

MIT © Lib Monkey Team

0.6.1

5 years ago

0.6.0-beta-rev4

5 years ago

0.6.0-beta-rev3

5 years ago

0.6.0-beta-rev2

5 years ago

0.6.0-beta

5 years ago

0.5.2

5 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.7

6 years ago

0.4.6

7 years ago

0.4.5

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago