Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @sap/cloud-sdk-test-util

cloud-sdk-test-utils

Package that contains utility functions for testing, like loading credentials or creating test destinations.

Index

Functions

getTestDestinationByAlias

  • Loads a destination matching the provided alias stored in systems.json and credentials.json. By default, this function starts looking in the directory the test process has been started in (i.e. '.') and traverses the file hierarchy upwards until it finds a systems.json and credentials.json file. Alternatively, you can supply paths to the systems and the credentials file directly.

    Throws an error when no systems.json can be found, the alias does not match any of the available destinations, the JSON is malformed or one of the supplied paths is invalid. Does not throw an error when no credentials.json can be found, but will print a warning.

    Parameters

    • alias: string

      The alias identifying the destination

    • Optional options: GetTestDestinationOptions

      References to the systems.json and credentials.json files

    Returns Destination

    An array of destinations

getTestDestinations

  • Loads all destinations stored in systems.json and credentials.json files.

    By default, this functions starts looking in the directory the test process has been started in (i.e. '.') and traverses the file hierarchy upwards until it finds a systems.json and credentials.json file. Alternatively, you can supply paths to the systems and the credentials file directly.

    Throws an error when no systems.json can be found, the JSON is malformed or one of the supplied paths is invalid. Does not throw an error when no credentials.json can be found, but will print a warning.

    Parameters

    Returns Destination[]

    An array of destinations

mockAllTestDestinations

  • Add all destinations from the systems.json and credentials.json files to the destinations environment variable.

    Throws an error if a destination with the same name as the given test destinations already exists.

    Parameters

    Returns void

mockTestDestination

  • Add a destination with the given name from the systems.json and credentials.json files to the destinations environment variable.

    Throws an error if a destination with the same name as the given test destination already exists.

    Parameters

    • name: string

      Name of the test destination to add to the destinations environment variable

    • Optional options: GetTestDestinationOptions

      References to the systems.json and credentials.json files

    Returns void

setTestDestination

  • Set a given destination in the destinations environment variable.

    Throws an error if a destination with the same name as the given test destination already exists.

    Parameters

    • destination: Destination

      Test destination to add to the destinations environment variable

    Returns void

unmockAllTestDestinations

  • unmockAllTestDestinations(): void
  • Removes all test destinations stored in systems.json and credentials.json files or added through [[setTestDestination()]] from the destinations environment variable.

    This function should be called to invert the behavior of [[mockAllTestDestinations()]] and other add single mocked destination functions.

    Returns void

unmockTestDestination

  • unmockTestDestination(name: string): void
  • Removes a destination with the given name from the destinations environment variable. If the given destination name is not found calling this function has no effect. This function should be called to invert the behavior of [[mockTestDestination()]] and [[setTestDestination()]].

    Parameters

    • name: string

      Name of the mocked destination to remove

    Returns void