Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocking prompt answers without access to the specific enquirer instance used to prompt #409

Open
Josh-Walker-GM opened this issue Nov 11, 2022 · 3 comments

Comments

@Josh-Walker-GM
Copy link

Hi all,

I've been looking to do some jest tests which involve functions which prompt. I did have a read through the README and this repo's own tests but I couldn't find an example of mocking responses without first having added event handlers to a specific instance of enquirer which is then used to perform the prompting.

Can you provide any guidance on this? Apologies in advance if this was already covered in #234 but reading over that issue didn't help me.

Thanks in advance, Josh.

@jonschlinkert
Copy link
Member

Sorry for the very late reply @Josh-Walker-GM.

I think we'll have a better solution for this in the next version of enquirer. Currently, it's not as easy as I'd like it to be. There was a lot of focus on getting prompts to render correctly in the terminal, so a lot of the functionality and unit tests are focused on that as well.

I know this issue is quite old, so I understand if you're no longer using enquirer or even thinking about this stuff. But for you or anyone else who is trying to achieve the same thing, it would help to know more about the use case. Examples of unit tests you'd like to be able to do would be great.

@Josh-Walker-GM
Copy link
Author

Hey @jonschlinkert no worries! We are still using enquirer and I think we tried to work around testing that involved faking the prompt inputs in the way that I was finding difficult. I'll try to find a more detailed example of what we were trying to do and update here shortly.

@jonschlinkert
Copy link
Member

We are still using enquirer and I think we tried to work around testing that involved faking the prompt inputs in the way that I was finding difficult

I think it's difficult too, I agree on this completely.

'll try to find a more detailed example of what we were trying to do and update here shortly.

Thank you! no pressure at all. If you find time that would be great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants