Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

ngMock contains unannotated functions #13542

Closed
bisubus opened this issue Dec 15, 2015 · 9 comments
Closed

ngMock contains unannotated functions #13542

bisubus opened this issue Dec 15, 2015 · 9 comments

Comments

@bisubus
Copy link

bisubus commented Dec 15, 2015

ngMock contains unannotated functions, i.e.

fn = function($provide) {

modules.unshift(function($injector) {

This prevents angular-mocks.js from being minified.

The problem was conditional (angular.mock.module({ mockedService: ... }) syntax was incompatible with minification before this commit), now it throws

[$injector:modulerr] Failed to instantiate module function (e){l.$providerInjector=e} due to:
Error: [$injector:unpr] Unknown provider: e
http://errors.angularjs.org/1.5.0-beta.2/$injector/unpr?p0=e

unconditionally.

@Narretz
Copy link
Contributor

Narretz commented Dec 15, 2015

Probably happens because ngMock isn't usually minified, because it should only run in tests, where minification isn't really needed. But we should probably fix it anyway.

@Narretz Narretz added this to the Backlog milestone Dec 15, 2015
@gkalpak
Copy link
Member

gkalpak commented Dec 15, 2015

Indeed I don't think it is intended to be minified. (In fact we are not producing a angular-mocks.min.js as part of our build.)
Why minify it ?

@szimek
Copy link

szimek commented Dec 15, 2015

@gkalpak I just modified our Gulp file to prevent minification of angular-mocks.js as a workaround for this issue. Previously, we just added angular-mocks.js to a list of all external JS files (but only if ENV === "test") that later all ended up as a single vendor.js file, which is loaded in index.html. It was just much easier to load it like this, especially for e2e tests.

@gkalpak
Copy link
Member

gkalpak commented Dec 15, 2015

OK, from a quick search, this has been brought up #3534 and #4448 before.

The last comment from @IgorMinar sums it up nicely, I think:

[...] We have no way to test it right now, so if we break it in the future, we'll fix it when someone complains.

So, @szimek, did you just complain ? 😄

@szimek
Copy link

szimek commented Dec 15, 2015

@gkalpak I just wanted to explain why people minify it 😄 I found a workaround for it, so it's fine for me as it is, but I suspect there are a lot more people who just add angular-mocks.js to their standard pipeline that minifies everything and will complain later on 😄

@bisubus
Copy link
Author

bisubus commented Dec 15, 2015

@gkalpak It is rare scenario but it exists, I've experienced problems after 1.5.0-beta.2. I test here that class detection will fail in transpiled and minified code on some condition, while it will pass on another condition. Without mgMock being fixed, I have to revise the way the specs are being bundled.

bisubus added a commit to ex-machine/ng-classified that referenced this issue Feb 8, 2016
bisubus added a commit to ex-machine/ng-classified that referenced this issue Feb 8, 2016
bisubus added a commit to ex-machine/ng-classified that referenced this issue Feb 9, 2016
gkalpak added a commit to gkalpak/angular.js that referenced this issue Feb 17, 2016
It is not common, but some workflows result in `angular-mocks` being minified.

Fixes angular#13542
@gkalpak
Copy link
Member

gkalpak commented Feb 18, 2016

@bisubus, @szimek, could you try out this angular-mocks.js and see if it works for you ?

@messo
Copy link

messo commented Feb 23, 2016

@gkalpak, we had the same issue as OP, and I have just tried your build and it is working for us 👍 Thanks! It would be nice to see this in 1.5.1

@gkalpak
Copy link
Member

gkalpak commented Feb 23, 2016

Thx, @messo, for the feedback. If it doesn't make it into v1.5.1 it will sure make it into v1.5.2 (but let's think positive 😛 )

gkalpak added a commit that referenced this issue Feb 23, 2016
It is not common, but some workflows result in `angular-mocks` being minified.

Fixes #13542

Closes #14073
@petebacondarwin petebacondarwin mentioned this issue Oct 9, 2016
3 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants