You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using Karma for unit tests and Webpack for bundling. I get the following error when running tests:
HeadlessChrome 80.0.3987 (Windows 10.0.0) SiteDocsController updates site when documents id is changed FAILED
Error: [$controller:ctrlreg] The controller with the name 'SiteDocsController' is not registered. https://errors.angularjs.org/1.7.9/$controller/ctrlreg?p0=SiteDocsController
at eval (webpack:///./node_modules/angular/angular.js?:141:12)
at $controller (webpack:///./node_modules/angular/angular.js?:11683:17)
at node_modules/angular-mocks/angular-mocks.js:2555:14
at UserContext. (tests/unit/site-docs.controller.test.js:22:18)
Expected spy updateSite to have been called.
at UserContext. (tests/unit/site-docs.controller.test.js:69:40)
so basically it doesn't seem to be initializing the SiteDocsController code.
The SiteDocsController file looks like this:
'use strict';
export default angular
.module('app.core')
.controller('SiteDocsController', SiteDocsController);
SiteDocsController.$inject = ['$scope'];
function SiteDocsController($scope) {
//... code here
}
I tried importing the lazily loaded files in a separate file and then adding that file to Karmas files in config. This worked except that the tests get stuck. Maybe a promise is not resolving?
Okay, the tests getting stuck was an unrelated issues to this. Apparently we just hit the threshold of having too many tests and we ran out memory. Allocating more fixed the issue, and including the lazily loaded files in a separate file for the Karma tests seem to work fine for now.
Hey,
We are using Karma for unit tests and Webpack for bundling. I get the following error when running tests:
so basically it doesn't seem to be initializing the SiteDocsController code.
The SiteDocsController file looks like this:
And I import it dynamically like so:
This works great when running the app, but when testing it, not so much.
Here is our Karma config:
So how can I initialize dynamically loaded files in the projects unit tests? Thank you!
The text was updated successfully, but these errors were encountered: