karma-ios-hybrid-app-launcher
:warning: This is pre-production software and not recommended for production use.
A karma launcher for hybrid apps on iOS.
Use this launcher to run karma tests in a webview-based iOS app.
Installation
npm install -D karma-ios-hybrid-app-launcher
Requirements
Xcode should be installed on the system. /usr/bin/xcodebuild
should exist on the system.
Manual Cleanup
This plugin will leave a simulator on your system named "karma-ios-hybrid-app-simulator" (unless your config sets the "configSimulatorName" field). It will re-use this simulator on re-runs. It is up to the developer to manually delete this simulator if cleanup is desired.
Usage
Update your karma config to use this plugin and set it as a "browser", and also provide a config object with the hybrid native test app name and app path.
browsers: ["iOSHybridApp"],
plugins: ["karma-ios-hybrid-app-launcher", ],
iOSHybridApp: {
packageId: "ios-test-app",
appPath: path.resolve("./ios-test-app/ios-test-app.app"),
},
An example karma config is in this repo.
iOS Hybrid App Requirements
A url will be passed by Webdriver agent to start the app. This url points to Karma endpoint that will serve a page with Jasmine tests. This url is processed inside the view controller.
Debugging Karma Tests
If you want to be able to tap the "DEBUG" button on the karma test page that runs in the webview and have it load that debug page inside the webview (instead of opening in the browser) you'll need to implement the delegate method for WKNavigationDelegate
, see the example ios app.
Note that when you open the debug page the original karma (non-debug) page will navigate away so the karma runner will think it's disconnected from the original page and console output will show errors, but if you attach a remote debugger to your webview you will see that the debug page does actually run the karma tests. Auto watch won't work but in the debug tools you can just refresh the page after updating your tests.
Contributing
See the CONTRIBUTING doc.
Running the tests
npm run test
Debugging
There is a vs code debug profile for debugging the karma test. Just press F5
in vs code.