Mattias Rasmusson
Mattias Rasmusson

Reputation: 120

Karma configuration of unit tests of services with SignalR dependency

I am using Karma v 0.8.6 to run unit tests on my AngularJS project. In the project, I am using SignalR v 1.1.3. In order to use SignalR, I register the hubs with:

<script src="/signalr/hubs"></script>

This works fine when running Jasmine SpecRunner.html. However, I cannot figure out how to do the equivalent in Karma. I get the following error:

Chrome 31.0 (Windows): Executed 48 of 266[31m (29 FAILED)[39m
[1A[2K[31mChrome 31.0 (Windows) Field service query() should make get request to api/ParamSetting FAILED[39m
Error: SignalR: Error loading hubs. Ensure your hubs reference is correct, e.g. <script src='/signalr/hubs'></script>.

My karma.conf.js:

// list of files / patterns to load in the browser
files = [
JASMINE,
JASMINE_ADAPTER,
'js/jquery-*.js',
'js/angular-1.2.1.js',
'js/angular-route-1.2.0.js',
'js/jquery.signalR-1.1.3.js',
'/signalr/hubs',
'js/test/lib/angular/angular-mocks.js',
'js/angular-cookies-1.2.0.js',
'js/controllers/*.js',
'js/test/spec/*Spec*.js',
'js/directives/*.js',
'js/filters/*.js',
'js/services/*.js',
];

How can I register the hub route in the Karma configuration file?

Upvotes: 4

Views: 1704

Answers (1)

Stefan
Stefan

Reputation: 446

You can use a manually configured signalR proxy: http://www.asp.net/signalr/overview/signalr-20/hubs-api/hubs-api-guide-javascript-client#manualproxy

Upvotes: 5

Related Questions