funcunit-as-promised

0.0.4 • Public • Published

funcunit-as-promised

Promise-ified Funcunit.

Use it

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 = require("funcunit-as-promised");
 
var promise = fp.assertVisible(".no-sites");
 
promise.then(function(){
    console.log("SUCCESS");
}, function(){
    console.log("FAILURE");
});

assertVisible works like this:

  1. Immediately return a promise that the item will become visible
  2. Wait for the item to become visible within the default timeout period of 15 seconds
  3. If the element becomes visible, resolve the promise
  4. 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 = require("funcunit-as-promised");
 
fp.getText(".siteName")
.then(function(siteName){
    console.log("The site name is " + siteName);
});

Get functions return a promise, but that promise is resolved immediately, as there is no condition for funcunit-as-promised to poll for.

Lint it

$ npm run jshint

Build it

$ npm install
$ bower install
$ npm run builddist

Readme

Keywords

none

Package Sidebar

Install

npm i funcunit-as-promised

Weekly Downloads

0

Version

0.0.4

License

MIT

Last publish

Collaborators

  • yola-readonly
  • yola-engineers