Class sap.ui.test.OpaModule: sap/ui/test/Opa
One Page Acceptance testing.
Since: 1.22.
Constructor Summary
new sap.ui.test.Opa(extensionObject?)This class will help you write acceptance tests in one page or single page applications.
Field Summary
sap.ui.test.Opa.configthe global configuration of Opa.
Method Summary
sap.ui.test.Opa.extendConfig(options)Extends and overwrites default values of the sap.ui.test.Opa#.config.
extendConfig()Calls the static extendConfig function in the Opa namespace sap.ui.test.Opa#.extendConfig
Constructor Detail
new sap.ui.test.Opa(extensionObject?)
This class will help you write acceptance tests in one page or single page applications. You can wait for certain conditions to be met.
Parameters:
{object} | extensionObject? | An object containing properties and functions. The newly created Opa will be extended by these properties and functions using jQuery.extend. |
Field Detail
sap.ui.test.Opa.config
the global configuration of Opa. All of the global values can be overwritten in an individual waitFor call. The default values are:
- arrangements: A new Opa instance
- actions: A new Opa instance
- assertions: A new Opa instance
- timeout : 15 seconds, is increased to 5 minutes if running in debug mode e.g. with URL parameter sap-ui-debug=true
- pollingInterval: 400 milliseconds
Method Detail
sap.ui.test.Opa.emptyQueue(): jQuery.promise
Waits until all waitFor calls are done.
Returns:
{jQuery.promise} | If the waiting was successful, the promise will be resolved. If not it will be rejected |
sap.ui.test.Opa.extendConfig(options)
Extends and overwrites default values of the sap.ui.test.Opa#.config. Sample usage:
var oOpa = new Opa();
// this statement will will time out after 15 seconds and poll every 400ms.
// those two values come from the defaults of sap.ui.test.Opa#.config.
oOpa.waitFor({
});
// All wait for statements added after this will take other defaults
Opa.extendConfig({
timeout: 10,
pollingInterval: 100
});
// this statement will time out after 10 seconds and poll every 100 ms
oOpa.waitFor({
});
// this statement will time out after 20 seconds and poll every 100 ms
oOpa.waitFor({
timeout: 20;
});
Parameters:
{object} | options | The values to be added to the existing config |
- Since:
- 1.40 The own properties of 'arrangements, actions and assertions' will be kept. Here is an example:
// An opa action with an own property 'clickMyButton' var myOpaAction = new Opa(); myOpaAction.clickMyButton = // function that clicks MyButton Opa.config.actions = myOpaAction; var myExtension = new Opa(); Opa.extendConfig({ actions: myExtension }); // The clickMyButton function is still available - the function is logged out console.log(Opa.config.actions.clickMyButton); // If var mySecondExtension = new Opa(); mySecondExtension.clickMyButton = // a different function than the initial one Opa.extendConfig({ actions: mySecondExtension }); // Now clickMyButton function is the function of the second extension not the first one. console.log(Opa.config.actions.clickMyButton);
sap.ui.test.Opa.getContext(): object
Gives access to a singleton object you can save values in. Same as sap.ui.test.Opa#getContext
- Since:
- 1.29.0
Returns:
{object} | the context object |
sap.ui.test.Opa.resetConfig()
Reset Opa.config to its default values. All of the global values can be overwritten in an individual waitFor call.
The default values are:
- arrangements: A new Opa instance
- actions: A new Opa instance
- assertions: A new Opa instance
- timeout : 15 seconds, is increased to 5 minutes if running in debug mode e.g. with URL parameter sap-ui-debug=true
- pollingInterval: 400 milliseconds
- Since:
- 1.25
extendConfig()
Calls the static extendConfig function in the Opa namespace sap.ui.test.Opa#.extendConfig
getContext(): object
Gives access to a singleton object you can save values in. This object will only be created once and it will never be destroyed. That means you can use it to save values you need in multiple separated tests.
Returns:
{object} | the context object |
waitFor(options): jQuery.promise
Queues up a waitFor command for Opa. The Queue will not be emptied until sap.ui.test.Opa#.emptyQueue is called. If you are using sap.ui.test.opaQunit, emptyQueue will be called by the wrapped tests.
If you are using Opa5, waitFor takes additional parameters. They can be found here: sap.ui.test.Opa5#waitFor. Waits for a check condition to return true, in which case a success function will be called. If the timeout is reached before the check returns true, an error function will be called.
Parameters:
{object} | options | These contain check, success and error functions |
{int} | oOptions.timeout? | default: 15 - (seconds) Specifies how long the waitFor function polls before it fails. |
{int} | oOptions.pollingInterval? | default: 400 - (milliseconds) Specifies how often the waitFor function polls. |
{function} | oOptions.check? | Will get invoked in every polling interval. If it returns true, the check is successful and the polling will stop. The first parameter passed into the function is the same value that gets passed to the success function. Returning something other than boolean in the check will not change the first parameter of success. |
{function} | oOptions.success? | Will get invoked after the check function returns true. If there is no check function defined, it will be directly invoked. waitFor statements added in the success handler will be executed before previously added waitFor statements |
{string} | oOptions.errorMessage? | Will be displayed as an errorMessage depending on your unit test framework. Currently the only adapter for Opa is QUnit. This message is displayed there if Opa has reached its timeout but QUnit has not yet reached it. |
Returns:
{jQuery.promise} | A promise that gets resolved on success |