bhauman / devcards

Devcards aims to provide a visual REPL experience for ClojureScript
1.53k stars 113 forks source link

Helpers to generate test data #112

Closed olivergeorge closed 8 years ago

olivergeorge commented 8 years ago

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.

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:

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

olivergeorge commented 8 years ago

Example lorem-ipsum generator

olivergeorge commented 8 years ago

Here's some proof of concept code

bhauman commented 8 years ago

I think this really deserves a good look, time and use will be needed to see how well used something like this will be. I love the idea...

I really see it as a separate library in the mean time so that these ideas can develop and iterate.

This is such new and fertile ground.

olivergeorge commented 8 years ago

Thanks Bruce. It's an interesting area indeed! I think I can isolate the new concepts so a devcards lib should work. I won't try for tight integration from the start. If the ideas prove sane they can absorbed/integrated.

olivergeorge commented 8 years ago

Quick note of some prior art: https://juxt.pro/blog/posts/generative-ui-clojure-spec.html

olivergeorge commented 8 years ago

Righto, I'll be working on this here:

https://github.com/olivergeorge/devcards-vs-clojure-spec

Would be happy to work collaboratively / share access.