Options
All
  • Public
  • Public/Protected
  • All
Menu

Class InteractionSpecHelper

A wrapper class for Driver with high level API for testing CLI interactions with libraries like jasmine, jest, mocha (uses expect())

Hierarchy

Index

Constructors

constructor

  • Parameters

    • client: Driver
    • Optional expectations: object
      • expectNotToContain: function
          • (actual: string, expected: string): any
          • Parameters

            • actual: string
            • expected: string

            Returns any

      • expectToContain: function
          • (actual: string, expected: string): any
          • Parameters

            • actual: string
            • expected: string

            Returns any

    Returns InteractionSpecHelper

Properties

data

data: function

Type declaration

    • Parameters

      • s: string

      Returns Promise<string | false | DriverError>

Methods

clear

  • clear(): Promise<void>

commandTaking

  • commandTaking(ms: number, exitCode?: number, stdout?: string, stderr?: string): string
  • Parameters

    • ms: number
    • Optional exitCode: number
    • Optional stdout: string
    • Optional stderr: string

    Returns string

controlC

  • controlC(): Promise<void>
  • Returns Promise<void>

destroy

  • destroy(): void

execCommandTaking

  • execCommandTaking(ms: number, exitCode?: number, stdout?: string, stderr?: string): Promise<void>
  • Parameters

    • ms: number
    • Optional exitCode: number
    • Optional stdout: string
    • Optional stderr: string

    Returns Promise<void>

expectExitWith

  • expectExitWith(zeroExitCode?: boolean | number): Promise<number>
  • This could not work on some situations, if so preffer to use [expectExitWith]

    Parameters

    • Optional zeroExitCode: boolean | number

    Returns Promise<number>

expectLastExitCode

  • expectLastExitCode(zeroExitCode?: boolean): Promise<void>
  • This could not work on some situations, if so preffer to use [expectExitWith]

    Parameters

    • Optional zeroExitCode: boolean

    Returns Promise<void>

getLastExitCode

  • getLastExitCode(): Promise<number>
  • Returns last process exit code or undefined if not possible. IMPORTANT: relies on $? and echo so most probably only works in unix (tested on macOs and Linux).

    This is useful on interactive applications that inquire some data and finally do some processing, in which they could fail with an excepiton. no matter if the processing takes time, we enter echo $? commands with an identifier that will be only executed after the application exits returning its exit code.

    However notice that while the app is running, althouhg not executed we are still writing to its stdin so use it when you know the app is no longer litening for relevant data, just makind final processing and exit, this is by waiting some time or in those cases where a key combination was presend to exit (q).

    TODO: example with "more" command

    Returns Promise<number>

getStrippedALlData

  • getStrippedALlData(): Promise<string>

waitForStrippedDataToInclude

  • waitForStrippedDataToInclude(s: string): Promise<string | false | DriverError>

Generated using TypeDoc