Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generators for values of object shapes always generate {} #86

Open
glittershark opened this issue May 1, 2018 · 1 comment
Open

Generators for values of object shapes always generate {} #86

glittershark opened this issue May 1, 2018 · 1 comment

Comments

@glittershark
Copy link

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"
@Zalathar
Copy link

Zalathar commented May 3, 2018

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 }))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants