Skip to content

Instantly share code, notes, and snippets.

@thatkookooguy
Last active July 19, 2018 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thatkookooguy/df348bb5b929442221c9b64c0506f157 to your computer and use it in GitHub Desktop.
Save thatkookooguy/df348bb5b929442221c9b64c0506f157 to your computer and use it in GitHub Desktop.
  • create @cliBefore(functionName) decorator. the function itself will get the @cliBeforeEach result object
  • create @cliAfter(functionName) decorator. the function itself will get the @cliAfterEach result object
  • generate a mock cli library

generate a mock cli library

This will generate an <cli_name>-mock.js library with the following methods:

  • <cli_name>-mock.inject(parentElement, onboardingFlowName) - will inject a terminal object with the onboarding flow loaded. if no onboardingFlowName is given, runs the basic mock flow (supports help output and shows general output if defined)
  • <cli_name>-mock.defineOnboarding(name, flow) - will create an onboarding flow. the flow param is an array of objects. each object is a step with the following attributes:
const firstStep = {
  description: 'welcome! to start, please run "myCli configure myEmail@gmail.com"',
  forcedRun: 'myCli configure myEmail@gmail.com'
  output: 'this is the example output!'
};

then, the onboarding will be less generic and guide the user to run a speicific flow. The only other functions the user can run in this mode besides the defined function, is the --help functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment