vorpal
vorpal copied to clipboard
how do i unit test a vorpal app?
Can anyone offer advice on unit testing a vorpal app? I'm unclear on how to setup my assertions. i.e. what do I run to get values to compare against?
http://stackoverflow.com/questions/40247962/how-do-i-approach-unit-testing-a-vorpal-cli-app
Will be interesting to see if this is a documentation or a feature request issue. :)
@Shakyamuni177te lol, well i did see a "questions" label. I'll cross post to the SO channel.
If I wrote unit tests for each of the projects in the examples, would that help answer this question?
@LongLiveCHIEF that would be neat, thanks. @dthree also suggested I review the tests on Cash, but i haven't checked it out yet.
@komplexb I unit tested launch, but I do not claim they are elegant :)
I'm dealing with the same problem: no idea where to start.
It's impossible to test using something like child_process.execSync
: the output result is full of extra characters and you can't do a comparisons with that.
The problem also comes when you combine inquirer
prompts in your cli.
Any nice documentation for all this?
thanks! :)
Someone suggested I take a look @ https://github.com/dthree/cash/tree/master/test
I haven’t tried it yet, but I hope that helps.
From: Matteo Gabriele [email protected] Sent: 22 March 2017 05:50:36 To: dthree/vorpal Cc: Byron; Mention Subject: Re: [dthree/vorpal] how do i unit test a vorpal app? (#186)
I'm dealing with the same problem: no idea where to start.
It's impossible to test using something likechild_process.execSync: the output result is full of extra characters and you can't do a comparisons with that.
The problem also comes when you combine inquirer prompts in your cli. Any nice documentation for all this?
thanks! :)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/dthree/vorpal/issues/186#issuecomment-288362467, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADsf_T74rhqpHvEDYCZvphCcBXWptIm6ks5roPz8gaJpZM4KgTlI.
@komplexb thanks man! I was looking at it, but i can't spot an example using prompt. Have you tried?
Pinging this.
It would be really useful to be able to set up simple "send strings in, check what gets out" tests with Vorpal.
Actually it's not too complicated to setup a Vorpal app in such a way that it accepts a command, prints the result, and exits. From there it's only a matter of creating a shell script that executes commands and checks the results.
I've done something like this here (the app check if a command was provided as arguments and, if so, execute it and exit):
https://github.com/laurent22/joplin/blob/master/CliClient/app/app.js#L343
Then I've got this shell script to run the tests (the execCommand function is what's calling Vorpal and returning stdout):
https://github.com/laurent22/joplin/blob/master/CliClient/app/cli-integration-tests.js
I think most vorpal apps can be tweaked in that way to allow running commands without starting the prompt
@komplexb Have you find out how to test the vorpal app yet? I mean the vorpal with prompt.
This project has been dead for more than 5 years. Better use an alternative such as terminal-kit