leebyron / testcheck-js

Generative testing for JavaScript

Home Page:http://leebyron.com/testcheck-js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generators for values of object shapes always generate `{}`

glittershark opened this issue · comments

Per the documentation, I'm trying to generate a simple object shape like so:

gen.sample({ x: gen.string })

But the output of the string generator is always just an empty object:

      [ { x: {} },
        { x: {} },
        { x: {} },
        { x: {} },
        { x: {} },
        { x: {} },
        { x: {} },
        { x: {} },
        { x: {} },
        { x: {} } ]

Relevant parts of my yarn.lock:

jasmine-check@^1.0.0-rc.0:
  version "1.0.0-rc.0"
  resolved "https://registry.yarnpkg.com/jasmine-check/-/jasmine-check-1.0.0-rc.0.tgz#117728c150078ecf211986c5f164275b71e937a4"
  dependencies:
    testcheck "^1.0.0-rc"

testcheck@^1.0.0-rc, testcheck@^1.0.0-rc.2:
  version "1.0.0-rc.2"
  resolved "https://registry.yarnpkg.com/testcheck/-/testcheck-1.0.0-rc.2.tgz#11356a25b84575efe0b0857451e85b5fa74ee4e4"

From what I can tell, the documentation on the website seems to describe a version that hasn't been formally released yet.

In the meantime, you should be able to work around this discrepancy by surrounding your struct-of-generators with a call to gen.object:

gen.sample(gen.object({ x: gen.string }))