Karma Jasmine Cordova plugins

Joseph Briggs

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.

DaveAlden

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to set up unit testing of cordova app using AngularJS, Jasmine and Karma

From Dev

Karma-jasmine not installing

From Dev

Karma Jasmine NPM config

From Dev

Karma not running jasmine specs

From Dev

Testing $interval in Jasmine/ Karma

From Dev

Jasmine with Karma: Ajax not working

From Dev

Isolation with Angular on karma jasmine

From Dev

Karma Jasmine NPM config

From Dev

Testing $interval in Jasmine/ Karma

From Dev

Does Karma coexist with Jasmine?

From Dev

Updating the version of Jasmine used in karma-jasmine

From Dev

Jasmine and Karma with Jasmine gives different results

From Dev

Spy on setTimeout and clearTimeout in Karma and Jasmine

From Dev

Karma/Jasmine spec -- Expected { } to equal { }

From Dev

Jasmine 2.0 SpecRunner vs Karma

From Dev

Karma Jasmine AngularJS module not defined

From Dev

Karma/Jasmine/PhantomJs: undefined is not a constructor

From Dev

Testing an AngularJS factory with Karma (Jasmine)

From Dev

Integration Testing AngularJS + Karma + Jasmine

From Dev

karma jasmine not executing all tests

From Dev

Testing a Controller using Jasmine in Karma

From Dev

$compile not compiling templates in Karma/Jasmine

From Dev

karma + jasmine, ReferenceError: browser is not defined

From Dev

ANT task for calling Karma/Jasmine

From Dev

karma + jasmine + webpack: module is not a function

From Dev

Karma +Jasmine +Angular "Argument is not a function"

From Dev

Jasmine/Karma not finding Angular modules

From Dev

Unit Test for Login with Jasmine and Karma

From Dev

Karma Jasmine AngularJS module not defined