FuncUnit is a jquery-based testing library that allows functional application tests to run right in the browser. It allows us to open our application in a popup window, and drive the application from JS code. Unfortunately, the default FuncUnit API makes a lot of assumptions about how it will be used, and is not easily paired with modern test harnesses or other asynchronous code like yotest.js. This can lead to frustration when writing and debugging tests.
Funcunit-as-promised is yotest's very thin wrapper around FuncUnit which exposes a promise-based interface. This in turn improves error-handling, asserts, and debug messages in our tests. The promise-based interface also makes it much easier to combine FuncUnit with the promise-based yotest.js API.
'Assert function' Example
If we want to assert that an element is visible, we do this:
var fp = ; var promise = fp; promise;
assertVisible works like this:
- Immediately return a promise that the item will become visible
- Wait for the item to become visible within the default timeout period of 15 seconds
- If the element becomes visible, resolve the promise
- If the element never appears reject the promise
The other funcunit-as-promised assert functions also use a polling mechanism like this.
'Get function' Example
If we want to simply get the text of an element, we do this:
var fp = ; fp;
Get functions return a promise, but that promise is resolved immediately, as there is no condition for funcunit-as-promised to poll for.
$ npm run jshint
$ npm install
$ bower install
$ npm run builddist