Unit testing Kibana plugin

I am writing unit-test based on Karma and ng-mock.
While I load

import $ from 'jquery';
import _ from 'lodash';
import expect from 'expect.js';
import ngMock from 'ng_mock';
import sinon from 'auto-release-sinon';
import VisProvider from 'ui/vis';

describe('testing my vis', function () {
beforeEach(ngMock.module('kibana','my_plugin'));
//or beforeEach(ngMock.module('kibana','kibana/my_plugin'));
//or beforeEach(ngMock.module('kibana/my_plugin'));
it('should ...');
});

it says:

[$injector:modulerr] Failed to instantiate module my_plugin due to:
Error: [$injector:nomod] Module 'my_plugin' is not available! You either misspelled the module 
name or forgot to load it. If registering a module ensure that you specify the dependencies as the 
second argument.

I checked there are no spelling mistakes.

My Kibana dev version is 5.4.0.
I am keeping my test files in test folder inside public and running unit test using npm run test:browser.
And package.json reads "test:browser": "plugin-helpers test:browser".

What may be the issue? What am i doing wrong?

That looks like your module was not registered with the angular dependency injection system. I guess you still have to somewhere import the file that contains the angular.module('my_plugin') or uiModule.get('my_plugin') line in order for it to be available.

Thanks.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.