How to test functions with prompts inside of them? #1979
-
|
How do I use the I read the docs on how to test this and I do not understand how to test my Any help is most appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi, the That later part is just much more complex. You can for example think of React app tests where the community needed to reimplement the DOM in Javascript (jsdom, happy-dom, etc) to make it possible. Similarly, to reach what you're looking for at a high level, I think we'd need to create a synthetic terminal for integration testing purposes. There's been some discussions on #1529 about this, and you'll see there's a recommendation of a library (I didn't test it myself.) If your app isn't overly complex, the simplest solution will be to rely on mocking the inquirer prompts. |
Beta Was this translation helpful? Give feedback.
Hi, the
@inquirer/testingpackage scope right now really is to test custom prompts; not full fledge app.That later part is just much more complex. You can for example think of React app tests where the community needed to reimplement the DOM in Javascript (jsdom, happy-dom, etc) to make it possible. Similarly, to reach what you're looking for at a high level, I think we'd need to create a synthetic terminal for integration testing purposes. There's been some discussions on #1529 about this, and you'll see there's a recommendation of a library (I didn't test it myself.)
If your app isn't overly complex, the simplest solution will be to rely on mocking the inquirer prompts.