A simple Gruntfile.js to test your "titaniumified" common js module 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 installRun the TiShadow server in another terminal:
tishadow serverRun this:
gruntOnce the app is running run this in another terminal:
cd /path/to/your-module/ti-module-tester
grunt testIf you don't want to open a new terminal you can run
cd ti-module-tester
grunt ; grunt test...wait your app is running then CTRL+C and that's it!
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
- and build the app
Required for setup the environment
It will:
- Update/copy your module specs
- Run
tishadow specin 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
