inquirerjs

what does `program.parse(process.argv)` do in commander.js?

丶灬走出姿态 提交于 2021-01-29 07:40:58
问题 I want to user commander.js and inquirer.js to ask questions and collect the answer to create a User instance: // index.js const mongoose = require('mongoose'); const User = require('./model/user') const {addUser,listAllUsers,findUserByEmail,updateUser,deleteUser} = require('./model_methods/user_methods') const { program } = require('commander'); var inquirer = require('inquirer'); // connect to DB const db = mongoose.connect('mongodb://localhost:27017/myImportantDates', { useNewUrlParser:

How to write unit tests for Inquirer.js?

此生再无相见时 提交于 2019-12-07 04:55:56
问题 I was wondering how to write unit tests for the npm package Inquirer.js, which is a tool to make CLI package more easily. I have read this post but I was't able to make it works. Here is my code that needs to be tested: const questions = [ { type: 'input', name: 'email', message: "What's your email ?", }, { type: 'password', name: 'password', message: 'Enter your password (it will not be saved neither communicate for other purpose than archiving)' } ]; inquirer.prompt(questions).then(answers

How to write unit tests for Inquirer.js?

孤街醉人 提交于 2019-12-05 09:41:21
I was wondering how to write unit tests for the npm package Inquirer.js , which is a tool to make CLI package more easily. I have read this post but I was't able to make it works. Here is my code that needs to be tested: const questions = [ { type: 'input', name: 'email', message: "What's your email ?", }, { type: 'password', name: 'password', message: 'Enter your password (it will not be saved neither communicate for other purpose than archiving)' } ]; inquirer.prompt(questions).then(answers => { const user = create_user(answers.email, answers.password); let guessing = guess_unix_login(user);