mockdeep / typewiz

Automatically discover and add missing types in your TypeScript code
https://medium.com/@urish/manual-typing-is-no-fun-introducing-typewiz-58e3e8813f4c
1.1k stars 46 forks source link

Automatic test generator, at least automatic creation of mock data #97

Open manudss opened 5 years ago

manudss commented 5 years ago

For a long time, I dream of a tool that would automate or at least simplify the creation of tests. Indeed, when working with javascript, we often work with large json structures. And so to write the unit tests, we have to write mocks with all this data. And this is therefore very time-consuming, more than describing the test itself.

I would dream to have a tool, which when running an application, that it is able to record all the input output of a function, and then why not generate the tests of this function.

I have the impression that what the approach made by typewiz, could allow to realize that? At least record the inputs and outputs of each function. What do you think ? Would that be possible?

Ps: for now I have not yet managed to run typewiz.

urish commented 5 years ago

Hi @manudss, thanks for the feedback!

What you describe sounds feasible to some extent. At least in some cases, the inputs and outputs of functions can be captured automatically in run-time. Some matters that can complicate this are nested structures, callbacks and objects that have non-trivial behavior (such as DOM elements, sockets, etc.).

In fact, @shairez and I have been exploring something similar last year. You may want to speak to him as he's been doing a lot of work related to automated mocking for testing.