Skip to main content
Version: 9.0.0

App StateTracker

enableAppIsBusyEvaluator

Method to enable the StateTracker defined in your configuration file.

disableAppIsBusyEvaluator

Method to disable the StateTracker defined in your configuration file.

Example using both + I.store()

Here is the I.store page documentation link.

You can set a soft failure value for your application state tracker. According to the code below, if the controlled app is busy but meets the condition of a soft failure, a message will be logged inside your terminal, but the test will not be stopped. You can also decide to disable the AppIsBusyEvaluator and re-enable it after a certain number of actions.

.Given(`I can disable/enable AppIsBusyEvaluator`, async (I: Controller) => {
await I.goto(`anyUrl`);
await I.disableAppIsBusyEvaluator()
await I.store().set<TestMakerStoreInterfaceExample>(`appIsBusy.softFailure`, false)
console.log(await I.getCurrentUrl())
await I.enableAppIsBusyEvaluator()
try {
console.log(await I.getCurrentUrl())
throw Error(`should have thrown line above`)
} catch (error) {
await I.store().set<TestMakerStoreInterfaceExample>(`appIsBusy.softFailure`, true)
await I.expect(error.message).toContain(`App is Busy but no internal Errors happened. Check why the "condition" function is not returning "false`)
}
})

configurable-app-is-busy-options.ts

import { store } from "test-maker";

store.set(`appIsBusy.softFailure`, true);

export interface TestMakerStoreInterfaceExample {
appIsBusy: {
condition: () => Promise<boolean>;
softFailure: boolean | (() => Promise<boolean>),
retry: {
timeout: number | (() => Promise<boolean>),
interval: number | (() => Promise<boolean>)
}
};
}

export const configurableAppIsBusyOptions = {
condition: async () => {
return true;
},
softFailure: async () => {
const softFailureDynamicValue = store.get<TestMakerStoreInterfaceExample>(`appIsBusy.softFailure`);
console.log(`======================= controlled app is busy soft failure dynamic value is: ${softFailureDynamicValue} ======================= `);
return softFailureDynamicValue;
},
retry: {
timeout: 2000,
interval: 1000
}
};

Configuration file

import { configurableAppIsBusyOptions } from "./configurable-app-is-busy-options";
import { Configuration } from "test-maker";

const testMakerLocalConfig: Configuration = {
runner:{
isAppBusyEvaluator:configurableAppIsBusyOptions,
}
}