vorpal icon indicating copy to clipboard operation
vorpal copied to clipboard

how do i unit test a vorpal app?

Open komplexb opened this issue 7 years ago • 11 comments

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

komplexb avatar Oct 25 '16 18:10 komplexb

Will be interesting to see if this is a documentation or a feature request issue. :)

Shakyamuni177te avatar Oct 25 '16 18:10 Shakyamuni177te

@Shakyamuni177te lol, well i did see a "questions" label. I'll cross post to the SO channel.

komplexb avatar Oct 25 '16 19:10 komplexb

If I wrote unit tests for each of the projects in the examples, would that help answer this question?

LongLiveCHIEF avatar Oct 28 '16 23:10 LongLiveCHIEF

@LongLiveCHIEF that would be neat, thanks. @dthree also suggested I review the tests on Cash, but i haven't checked it out yet.

komplexb avatar Oct 29 '16 01:10 komplexb

@komplexb I unit tested launch, but I do not claim they are elegant :)

johnthepink avatar Dec 04 '16 03:12 johnthepink

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! :)

MatteoGabriele avatar Mar 22 '17 10:03 MatteoGabriele

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 avatar Mar 22 '17 15:03 komplexb

@komplexb thanks man! I was looking at it, but i can't spot an example using prompt. Have you tried?

MatteoGabriele avatar Mar 22 '17 15:03 MatteoGabriele

Pinging this.

It would be really useful to be able to set up simple "send strings in, check what gets out" tests with Vorpal.

PoignardAzur avatar Jun 26 '17 08:06 PoignardAzur

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

laurent22 avatar Jul 26 '17 23:07 laurent22

@komplexb Have you find out how to test the vorpal app yet? I mean the vorpal with prompt.

lansehuiyi6 avatar Oct 25 '18 06:10 lansehuiyi6

This project has been dead for more than 5 years. Better use an alternative such as terminal-kit

laurent22 avatar Sep 16 '23 06:09 laurent22