preboot/angularjs-webpack

ngMock function in global scope (module, inject, ...)

Mic75 opened this issue · 3 comments

Mic75 commented

Hi there,

Thanks for this boilerplate, very handful.
Do you know why the functions from ngMock are not available in the global scope of the spec file ?

For example, if I replace, angular.mock.module('app'); by module('app') (in app.spec.js:9), I am having an error saying that module is undefined.

AngularJS doc say that the function is published on windows for easy access, but it looks like something is going wrong when using when using karma+webpack.

phra commented

i'm quite sure that webpack is preventing it to patching window object. just use angular.mock.module() instead.

Mic75 commented

Thanks for the answer. Not quite correct though, since all jasmine functions are available on window (expect, spyOn, ...). It looks like jasmine successfully patch window but not angular.

Maybe something related to the order webpack is loading modules...

phra commented

yeah, i explained myself badly, probably the angular package is published with a UMD template so if you use a commonjs-like environment, like webpack, the package doesn't register itself on window.