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.
The alias identifying the destination
References to the systems.json
and credentials.json
files
An array of destinations
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.
References to the systems.json
and credentials.json
files
An array of destinations
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.
References to the systems.json
and credentials.json
files
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.
Name of the test destination to add to the destinations
environment variable
References to the systems.json
and credentials.json
files
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.
Test destination to add to the destinations
environment variable
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.
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().
Name of the mocked destination to remove
Copyright Ⓒ 2023 SAP SE or an SAP affiliate company. All rights reserved.
Version 2 Release
The SAP Cloud SDK has released version 2. Check the upgrade guide for more details. Make sure you understand our release policy.
@sap-cloud-sdk/test-util
This package contains utility functions for testing, like loading credentials or creating test destinations.
Installation
Usage
The test-util package makes writing tests for your SAP Business Technology Platform application more convenient.
For example, you can create a mock destination for your tests by using the function
mockTestDestination
.You need to save your system information in local file
systems.json
:and
credentials.json
:Support
The recommended way to get in touch with us is to create an issue in our github repository. Select the issue category
Bug
,Feature
orQuestion
depending on the nature of your request. We try to provide fixes, features and answers as soon as possible.Contribute
If you would like to contribute to the SAP Cloud SDK, please make yourself familiar with our contributing guidelines and follow the given instructions.
Links
License
The SAP Cloud SDK is released under the Apache License Version 2.0.