Scripts Pro / Enterprise
Kreya scripts (not to be confused with operation scripts, which define scripts and tests in operations) offer a way to arbitrarily control the execution flow of operations. Among other things, it allows you to create tests and view the results of them.
This can be useful in a range of scenarios. For example, if you want to start a long-running job and wait until it is finished:
// Invoke an operation that starts a long running job on the server
await kreya.invokeOperation('start-long-running-job');
let finished = false;
while (!finished) {
const result = await kreya.invokeOperation('fetch-job-status');
finished = result.success;
if (!finished) {
kreya.sleep(500);
}
}
// Now invoke an operation that fetches the job result and performs tests on it
await kreya.invokeOperation('fetch-job-result');
Another use case could be to run multiple operations concurrently:
// Start an operation, but do not wait for its completion (no await keyword)
const runningOperation = kreya.invokeOperation('long-running');
// Invoke some other operations in the meantime
await kreya.invokeOperation('operation1');
await kreya.invokeOperation('operation2');
// Now we wait for the long-running operation to complete
await runningOperation;
View all available properties and methods in the API reference.