Find file
Fetching contributors…
Cannot retrieve contributors at this time
93 lines (52 sloc) 6.26 KB


titanium-jasmine provides testing for Appcelerator’s Titanium Mobile applications using Pivotal’s Jasmine as the core testing framework.

How it works

Titanium Mobile translates your hard won JavaScript skills into native applications that perform and look just like they were written in Objective-C (iPhone and iPad) or Java (Android).

Jasmine is a BDD-style framework for JavaScript that makes your tests look awesome:

describe("titanium-jasmine", function() {
  it("should help you develop titanium applications", function() {

titanium-jasmine puts together Jasmine and Titanium Mobile, so you can write Jasmine tests that will run inside your iPhone, iPad and Android applications. titanium-jasmine is a really simple testing framework that will help you test your Titanium Mobile applications properly.

Instead of trying to mock all Titanium.* objects and functions, titanium-jasmine will run the tests on your simulator so you can keep using Titanium includes and helper functions on your code, thus making testing much easier.

* Screenshot: titanium-jasmine test results on the iPhone.


titanium-jasmine supports all Jasmine features from suites, specs and matchers to asynchronous testing, spying/mocking/faking and before/after functions.

How to start the project

Download the source code, go to the project root and type:

$ make run-iphone

* Tested with all Titanium Mobile SDK versions from 1.5.0 to 1.6.2. To change the SDK version, change the TI_SDK_VERSION configuration in the bin/ script.

To run the application on the iPad, type:

$ make clean && make run-ipad

* You just have to use “make clean” before the run command if you change the device type. If you’re using the same device between executions, it’s not necessary to execute “make clean” because it will force Titanium to re-compile the entire project again, which is considerably slow.

To run the application executing the tests, go to project root and type:

$ make test-iphone


$ make test-ipad

* Remember to execute “make clean” whenever you change the device type.

You don’t have to import the project on Titanium Developer. You can do that if you want, but I prefer to start from the command line. If you want to do this in your project too, just copy Makefile and the bin directory to your project.

How to use in your projects

This project comes with a sample application located in the same directory. You can inspect this sample app to understand how the testing structure works.

To use titanium-jasmine in your projects, just copy following files and modify the files accordingly.

  • Resources/test directory
  • Makefile

And add the following line to your Resources/app.js.


Here are some details about some key files and directories:

  • Resources/test/lib contains Jasmine library and the reporter that displays tests output on the application.
  • Resources/test/enabled.js is the file that controls if the application is in “test mode” or not. This file does not exist in the repository because it is created by the “make” script. When you start the application with the “make” command, this file will be created containing the configuration to start the test runner or not. If you want to know more about this, take a look at the Makefile file in the project root. The Makefile requires script to run.
  • Resources/test/tests.js contains the test startup code. You will have to add code to include all your test scripts in this file.
  • Resources/test/test_main.js is a sample file that contains the actual tests. You can (should) create as many files as you want, just remind to import all the modules on tests.js.

More info

If you want more info about how to use Makefiles in your Titanium Mobile projects, please take a look at my blog post about it.

If you want to see how I use titanium-jasmine on a real production project, please take a look at Yahoo! Meme’s source code on GitHub.

If you have any other questions, please contact me through Twitter or e-mail.


titanium-jasmine is licensed under Apache Public License (Version 2). See LICENSE for more details.

Developed by Guilherme Chapiewski.