I've been trying to understand searching various forums, but could not get to what I'm looking for. Partly because of my NodeJS ignorance. I'm just starting up.
My task is to unit test inquirer based CLI via Jest/Mocha. How do I mock and test this.
My cli.js looks like this -
var inquirer = require('inquirer');
var question = {
name: 'name',
message: 'Enter your name : '
};
inquirer
.prompt([question])
.then (function(response) {
console.log(JSON.stringify(response))
}
);
If I just were to ensure that the user passed value can't be longer than 10 characters, how do I write test for this.
Can someone point to what would my unit test code for this via Jest would be (ofcourse using any of the mocking packages).
Thanks in advance for your help !
Cli.js
Cli.unit.test.js (Cli.unit.test is a sibling file in same directory)