I am attempting to understand karma/jasmine with Cordova mobile app integration.
However my problem is that I would like to test for example WifiWizard
(cordova plugin) on my unit test.
e.g:
describe('WifiWizard', () => {
it('Is defined', () => {
expect(WifiWizard).toBeDefined();
});
it('Not Empty Object', () => {
expect(WifiWizard).not.toEqual({});
});
});
But I require cordova.js to be included, alas cordova.js is being included in the index.html file in my www root folder.
Any help would be greatly appreciated.
WifiWizard is a plugin hence it contains native code as well as Javascript. The only way to test this would be either to stub out the plugin's JS API to return mock responses, or to test the actual plugin on an real mobile device (as opposed in a browser).
You can actually do this using Appium in conjunction with wd-bridge in order to remotely control the device. I've successfully done this, using Protractor tests to remotely drive Android and iOS devices running a Cordova-based app. Protractor is more suitable for this kind of end-to-end testing than Karma. There's a useful blog post that may help you to set up the test environment should you decide to go down this route.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments