Created
February 12, 2022 22:01
-
-
Save chico/68d4f90069457c6c3f18f540328d5a09 to your computer and use it in GitHub Desktop.
5 - Testing with sinon & mock-stdin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inquirer from 'inquirer' | |
import sinon from 'sinon' | |
const stubPrompts = (results) => { | |
const stub = sinon.stub(inquirer, 'prompt') | |
for (const [index, result] of results.entries()) { | |
stub.onCall(index).resolves({ result }) | |
} | |
return stub | |
} | |
... | |
stubPrompts(['1st answer', '2nd answer']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment