Test Automation
CloudIO Platform comes with an inbuilt test automation framework. You can create test scripts to automate the testing of both backend services & frontend UI interactions. Test scripts are written in JavaScript and can be auto-generated via. recording.

The test scripts are similar to Jest with chaijs assertions.
/* refer https://www.chaijs.com/api/bdd/ for more assertions */
beforeAll(async () => {
platform.showInfo("Before all...");
});
afterAll(async () => {
platform.showInfo("After all...");
});
beforeEach(async () => {
platform.showInfo("Before each...");
});
afterEach(async () => {
platform.showInfo("After each...");
});
test("Query Test", async () => {
// const rows = await find('Todos', { "filter": [], "limit": 2000, "offset": 0, "sort": { "id": 1 } });
// expect(rows.length).to.gt(0);
expect(1 + 1).to.eq(2);
});
test("Insert Test", async () => {
// const input = [{ "completed": "N", "fileUid": "01G2T3JJAREESW47ZYTHX43ZPG", "todo": "test test" }];
// const rows = await insertMany('Todos', input);
// expect(rows[0].lastUpdateDate).to.not.empty;
expect(1 + 1).to.eq(2);
});
test("Dummy Test", async () => {
// refer https://www.chaijs.com/api/bdd/ for more assertions
expect(1 + 1).to.eq(2);
});
/*
Find below the typescript definition for all the inbuilt functions available along with the standard ES2020 JavaScript
import { WSRequest, WSSuccessResponse, AllDatasources, Query, DBRow } from '@cloudio-saas/datasource-types';
import { Platform, UIDriver, MultiPostFunction, SinglePostFunction, TestFn, FnWithResult, FnWithResults, TestResult, SQLResult } from 'cloudio';
type DataSourceName = keyof AllDatasources;
declare global {
const platform: Platform;
const ui: UIDriver;
const expect: Chai.ExpectStatic;
declare function test(name: string, fn: TestFn): void;
declare function beforeAll(fn: TestFn): void;
declare function afterAll(fn: FnWithResults): void;
declare function beforeEach(fn: TestFn): void;
declare function afterEach(fn: FnWithResult): void;
declare function post(request: WSRequest, appUid: string): Promise<WSSuccessResponse<any>>;
declare function find<T extends DataSourceName>(ds: T, request: Query<AllDatasources[T]>): Promise<DBRow<AllDatasources[T]>[]>;
const insertMany = MultiPostFunction;
const updateMany = MultiPostFunction;
const deleteMany = MultiPostFunction;
const insertOne = SinglePostFunction;
const updateOne = SinglePostFunction;
const deleteOne = SinglePostFunction;
declare function executeQuery(sql: string): Promise<SQLType>;
declare function executeUpdate(sql: string): Promise<SQLType>;
}
*/
With the record option, you can generate test scripts while navigating through the application flow. Once generated, you can further finetune the script as needed.

Last updated
Was this helpful?