ti-slag
Titanium faker API, Titanium app running on Node.js.
WORKING IN PROGRESS If vm crash, Please feedback with the code you run 😄
Why
- Want running code of Titanium on Node.js
- Want to run a unit test in Node.js only
- Not required simulator/emulator and iOS/Android device
Tasks
Full support of AlloyFull support of native module- gulp plugin
Test
Programmatically
Setup
$ cd path/to/your_app_project$ npm install ti-slag --save
Using
var path = slag = ; ;
API
IMPORTANT arguments chenged, since 0.0.7
<vm.context>
slag(string <file path>
, object <options>
)
object Classic
;
Alloy
Please be Alloy compiled before. $ alloy compile --config platform=ios
or $ alloy compile --config platform=android
var alloy = Alloy = alloy context = ; context; // This is Alloy controller
ti-slag stop the Alloy internal support, since 0.0.14.
Alloy loader now support, since 0.0.15.
file path
path/to/example.js
Titanium SDK version
- 5.2.0.GA
- 4.1.0.GA
- 4.0.0.GA
- 3.5.1.GA
platform
- ios
- android
device
Load the device profile.
;
Your device profile format.
e.g.
var profile = name: 'iPhone OS' osname: 'iphone' model: 'Simulator' version: '8.4' architecture: 'x86_64' ostype: '64bit' displayCaps: density: 'high' dpi: 320 platformWidth: 320 platformHeight: 568 ;
module
Native or CommonJS module simulate.
Titanium code
var anymodule = anything = anymodule; anything;
ti-slag code
;
strict mode
It throws an exception If you use a custom property.
- false
- true (default)
silent
console.*
, Ti.API.*
, alert
quiet.
- false (default)
- true
coverage
- false (default)
- true
Testing in mocha
And coverage.
Install the mocha, nyc and ti-slag
$ npm install mocha nyc ti-slag --save-dev
Edit the package.json
{
...
"scripts": {
"test": "mocha test.js",
"coverage": "nyc npm test && nyc report"
},
"config": {
"nyc": {
"exclude": [
"test.js",
"node_modules/",
"app/"
]
}
},
...
}
test.js
var assert = path = slag = ; ;
Run the test
$ npm test
Result
> Sandbox@1.0.0 test /Users/Kosuke/src/Sandbox
> mocha test.js
foo.js
✓ should does not throw exception
1 passing (18ms)
Coverage
Edit the test.js
var istanbul = collector = reporter = ; ;
CLI
Install
$ npm install ti-slag -g
Usage
$ cd path/to/your_app_project$ slag --sdk 4.0.0.GA --platform ios
Generate the faker API
If you want other Titanium SDK version, See the furnace.js. And required api.json.
License
MIT