I’m writing my new project Candy, and I’m writing a CLI for it.
The main project is tested with mocha and chia, but I’ve never seen anyone test a CLI before, nor any ways to do it.
How would you/did you approach this problem?
I’m writing my new project Candy, and I’m writing a CLI for it.
The main project is tested with mocha and chia, but I’ve never seen anyone test a CLI before, nor any ways to do it.
How would you/did you approach this problem?
For further actions, you may consider blocking this person and/or reporting abuse
Benjamin Arambide -
Chris Jarvis -
Gleidson Leite da Silva -
Oliver Bennet -
Top comments (3)
I think this project github.com/sstephenson/bats can come handy! I have never used it myself though. For me, it was always enough to write tests with mocha & chai (i.e. test that arguments are parsed correctly and your internal logic). What exactly do you want to achieve by testing via CLI?
I think you could probably write another small app if you really need to do testing right at the CLI that know what inputs and outputs to look for. A miniature "postman" for your app. I would submit that you should first make sure everything before the CLI is tested correctly. If you have internal tests for all logic/processing/CRUD in your application there is really very little to test at the CLI. What functionality or behavior are you wanting to test there that can't be tested internally?
I found mock-stdin quite handy.