No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
src
test/unit
.babelrc
.gitignore
.travis.yml
LICENSE
README.md
package.json
rollup.config.js
upgrade.sh
yarn.lock

README.md

logo

Build Status codecov npm GitHub license Maintenance Donate

Motivation

Type definitions in javascript can help adding type safety for classes. But should not make more complicated property based testing. This package aims to generate random objects based on their flow definitions

Installation

yarn add flow-runtime-faker -D or npm install flow-runtime-faker --save-dev

if you use only flow and not flow-runtime. You can use this plugin by:

  • yarn add flow-runtime babel-plugin-flow-runtime -D or npm install flow-runtime babel-plugin-flow-runtime --save-dev
  • add the next configuration for tests phase on your .babelrc
   {
   ...
    "env": {
       "test": {
           "plugins": [["flow-runtime", { "assert": false, "annotate": false }]]
       }
     }
   }

Usage

import faker from 'flow-runtime-faker'

type otherType {
    fuz: 42 | 7 | 32 | "Some" | "Some Other" | false
}

type myType = {
    foo: number,
    bar: number[],
    daz: string,
    don: otherType
}

let value = fake(test)

console.log(value)
/*
type myType = {
    foo: 10,
    bar: [1,6.40],
    daz: "something",
    don: {
        fuz: 42
    }
}
*/

Support

Done? Flow Type
number
string
boolean
null
void
numeric literals
string literals
boolean literals
union
maybe
optional
arrays
subtypes
function