Skip to content

Helpers to generate test data #112

@olivergeorge

Description

@olivergeorge

When developing UI views it's super-helpful to be able to generate sane test data. It saves time and it simplifies the process of checking views with different data.

Spec provides a simple way to declare the props required for a pure view. Spec generators (and spec generator overrides) provide a mechanism for generating interesting data for use.

Perhaps this something which could be baked into devcards.

  • User provides spec for view props
  • Dev card uses spec to generate props data
  • Dev card provides mechanism to generate new fresh data

Also it would be useful to "go back" to a particular version of the generated data (sounds a lot like the history feature). That should be possible if the seed used to generate the data is known/tracked. That's buried in test.check somewhere I think.

By design the spec generators start simple (e.g. lots of nils, 0's, 1's, empty strings... not interesting test data) but it's possible to provide generator overrides. It's probably critical to include some generators which produce "interesting" data:

  • lorem-ipsum generator
  • person name generator
  • interesting-date generator (they tend to be epoch +- a few seconds by default)
  • interesting-number generator (perhaps based on mean & standard dev to avoid lots of 0's and 1's)

Some handy "noun lists" would be good fodder for these generators.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions