A simple Gruntfile.js to test your "titaniumified" common js and iOS (Android coming soon) native modules in two commands using TiShadow (tishadow spec
for more information about run tests with TiShadow -> here)
Just clone this repo in your module folder and install dependencies:
git clone https://github.com/inakiabt/ti-module-tester
cd ti-module-tester
npm install
Run this:
grunt
...and that's it!
In case you want to test iOS native modules, just add this to your module package.json
:
{
"name": "your-module-name",
"version": "your-version", // It must match with the version in your manifest file
"titaniumManifest": {
"type": "iphone"
},
...
}
In case you don't want to clone this project in your project, you can clone it anywhere and use --module-dir /path/to/your/module
param.
This Gruntfile.js
provides some tasks to setup a temp Titanium app and test your module with it using TiShadow.
Tasks provided:
It will:
- Create a temp Titanium app
- Build your titaniumified module
- Install your module in the temp app
- Copy some jasmine utils
- Appify https://github.com/dbankier/TiShadow#tishadow-appify the app
- Build the app
- and run your tests
Required for setup the environment
It will:
- Update/copy your module specs
- Run
tishadow spec
in the temp app
Useful when you are developing the module specs
It will:
- Build your titaniumified module
- Install your module in the temp app
- Appify the app
- Build the app
Useful when you make changes on your module
utils-module/
utils.js
package.json
spec/
utils_spec.js
ti-module-tester/
utils.js
exports.sum = function(value1, value2){
return value1 + value2;
};
spec/utils_spec.js
var utils = require('utils');
describe('utils module', function(){
it("should return a + b", function () {
var a = 10, b = 30;
expect(utils.sum(a, b)).toEqual(a + b);
});
});
After setup the environment, running grunt test
I'll get something like this:
Iñaki Abete web: http://github.com/inakiabt email: inakiabt+github@gmail.com twitter: @inakiabt
Found a bug? Want to contribute and add a new feature?
Please fork this project and send me a pull request!
This library, ti-module-tester, is free software ("Licensed Software"); you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; including but not limited to, the implied warranty of MERCHANTABILITY, NONINFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA