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

Testing Generator with Custom Prompt Type #97

Closed
mfasman95 opened this issue Apr 21, 2020 · 1 comment
Closed

Testing Generator with Custom Prompt Type #97

mfasman95 opened this issue Apr 21, 2020 · 1 comment

Comments

@mfasman95
Copy link

mfasman95 commented Apr 21, 2020

I have added a new prompt type (autocomplete from https://www.npmjs.com/package/inquirer-autocomplete-prompt) and am noticing that the TestAdapter created by yeoman-test is not inserting the DummyPrompt for this new prompt type into the prompt module. This is causing an issues where I am unable to pass in mocked prompt answers for prompts of this new type. I am not sure if this is a bug. If it is not a bug, can I make a feature request for the ability to pass in a custom prompt type to the helpers so that it will properly create the DummyPrompt?

When I log the adapter in my current setup, here is what it looks like (note TestAdapter.promptModule.prompts.autocomplete being different from the other values in prompts:

TestAdapter {
  promptModule:
   { [Function: promptModule]
     prompts:
      { list: [Function: bound DummyPrompt],
        input: [Function: bound DummyPrompt],
        number: [Function: bound DummyPrompt],
        confirm: [Function: bound DummyPrompt],
        rawlist: [Function: bound DummyPrompt],
        expand: [Function: bound DummyPrompt],
        checkbox: [Function: bound DummyPrompt],
        password: [Function: bound DummyPrompt],
        editor: [Function: bound DummyPrompt],
        autocomplete: [Function: AutocompletePrompt] },
     registerPrompt: [Function],
     restoreDefaultPrompts: [Function] },
  diff: [Function],
  log:
   { [Function]
     _events: undefined,
     _eventsCount: 0,
     _maxListeners: undefined,
     setMaxListeners: [Function: setMaxListeners],
     getMaxListeners: [Function: getMaxListeners],
     emit: [Function: emit],
     addListener: [Function: addListener],
     on: [Function: addListener],
     prependListener: [Function: prependListener],
     once: [Function: once],
     prependOnceListener: [Function: prependOnceListener],
     removeListener: [Function: removeListener],
     off: [Function: removeListener],
     removeAllListeners: [Function: removeAllListeners],
     listeners: [Function: listeners],
     rawListeners: [Function: rawListeners],
     listenerCount: [Function: listenerCount],
     eventNames: [Function: eventNames],
     write: [Function: functionStub],
     writeln: [Function: functionStub],
     ok: [Function: functionStub],
     error: [Function: functionStub],
     skip: [Function: functionStub],
     force: [Function: functionStub],
     create: [Function: functionStub],
     conflict: [Function: functionStub],
     identical: [Function: functionStub],
     info: [Function: functionStub],
     table: [Function: functionStub] } }

This is the line where I register the new prompt type in the constructor of my generator:

this.env.adapter.promptModule.registerPrompt('autocomplete', autocompletePrompt);
@mfasman95
Copy link
Author

mfasman95 commented Apr 21, 2020

Nevermind - I was accessing the value at the wrong time during the run. It turns out my issue was something else entirely.

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

1 participant