mocking for Titanium
npm install mockti
|13||downloads in the last week|
|79||downloads in the last month|
|Version||1.1.1 last updated 5 months ago|
|Dependencies||underscore, eventemitter2, MD5, request|
mockti is a mocking framework for Titanium. It loads up a
of the Titanium API and creates a
Titanium object with all of the proper
objects and methods for testing code. Every proxy is an emitter (as in Ti
itself). Methods also emit an event
function::name when invoked.
Alternatively, one could use some test runner with this. This is the PhantomJS style approach.
How to use it
Install it like this
$ npm i mockti
Then, use it like this
var mockti = require('mockti'); // make it global Ti = mockti(); var xhr = Titanium.Network.createHTTPClient(); var view = Ti.UI.createView();
mockti() function takes as an argument the path to an
These are included with every sdk build. If you don't pass a path, it'll use
api.jsca, which currently is from 3.1.0 GA.
You'll probably want to require() some of the code in your
Currently I have my project setup with a
test folder which has a couple tests;
these require code out of Resources after requiring
mockti. Then, I attempt
requests, make assertions, etc.
You can also make http requests, which will go through the npm
Check out nock if you'd like to mock these
Simple types are asserted. For example, functions that accept a number or string will have their argument's type asserted.