Socket
Socket
Sign inDemoInstall

funcunit-as-promised

Package Overview
Dependencies
197
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    funcunit-as-promised

Promise based interface for funcunit


Version published
Maintainers
1
Install size
19.3 MB
Created

Changelog

Source

0.0.4

  • add timeout setter on main export

Readme

Source

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

FAQs

Last updated on 04 Apr 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc