Generating Random Data with JS Verify

node v4.9.1
version: 1.0.0
endpointsharetweet
const jsc = require('jsverify') // Creating arbitraries: const emailGenerator = jsc.asciinestring.generator.map(str => `${str}@example.com`) const arbUser = jsc.record({ first: jsc.asciinestring, last: jsc.asciinestring, email: jsc.bless({ generator: emailGenerator }) }) // lets test our user here: const checkOptions = { rngState: '074e9b5f037a8c21d6', tests: 2 } // lets test our user here: jsc.check(jsc.forall(jsc.integer, arbUser, (a, user) => { console.log({a, user}) return true }), checkOptions) // Because we pass in rngState above we will see the following every time: // {a: 14, user: { email: "x1E@example.com", first: "H=0y", last: "T" } } // {a: 2, user: { email: "Hz2@example.com", first: "xwr", last: "ViG" } }
Loading…

no comments

    sign in to comment