New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Angular 4 fails to provide MockBackend #15521
Comments
Please add a small reproduction |
Done, added. |
Although that happened after updating to Angular 4 RC4/5 provider = webpack_require.i(WEBPACK_IMPORTED_MODULE_0__angular_core["_46" /* resolveForwardRef */])(provider); Could it be a webpack related issue? So basically MockBackend is undefined running the app with a webpack-dev-server. Please note I'm using that not for tests, but for backendless development. |
Set all angular components to latest version 4.0, but reverted http module to 4.0 RC3 - and MockBackend provider now works as expected. Are there any changes I need to consider when moving to angular 4.0? |
There has been no changes.
|
I believe I am seeing a similar issue. If I comment out MockBackend in my providers the issue goes away. If I disable AOT, the issue goes away. Simple reproduction with angular-cli 1.0.0:
ERROR in ./src/$$_gendir/app/app.module.ngfactory.ts
|
same problem, MockBackend not available in aot. |
How i can run Angular 4 with MVC Asp.net ?? anybody please help |
Just tried this again with Angular version 4.0.3 and the issue still exists.
|
Same problem using Angular CLI 1.0.0 and Angular 4.0.0 |
@angular/http/testing used to publish a metadata structure which paralleled the .d.ts structure. This causes ngc to write incorrect imports for this bundle when compiling providers using MockBackend and other http testing classes. This change restructures the @angular/http/testing build a bit, modeling it after @angular/platform-browser-animations, and produces a FESM structure that has flat metadata. Fixes angular#15521.
@angular/http/testing used to publish a metadata structure which paralleled the .d.ts structure. This causes ngc to write incorrect imports for this bundle when compiling providers using MockBackend and other http testing classes. This change restructures the @angular/http/testing build a bit, modeling it after @angular/platform-browser-animations, and produces a FESM structure that has flat metadata. Fixes angular#15521.
I'm getting this error:
You can reproduce the error with using this project of mine. Removing Is there any alternative to |
I‘ve also got the same error on angular4 or ionic2/3 with " --prod"!
|
@angular/http/testing used to publish a metadata structure which paralleled the .d.ts structure. This causes ngc to write incorrect imports for this bundle when compiling providers using MockBackend and other http testing classes. This change restructures the @angular/http/testing build a bit, modeling it after @angular/platform-browser-animations, and produces a FESM structure that has flat metadata. Fixes angular#15521.
@angular/http/testing used to publish a metadata structure which paralleled the .d.ts structure. This causes ngc to write incorrect imports for this bundle when compiling providers using MockBackend and other http testing classes. This change restructures the @angular/http/testing build a bit, modeling it after @angular/platform-browser-animations, and produces a FESM structure that has flat metadata. Fixes #15521. PR Close #16390
@angular/http/testing used to publish a metadata structure which paralleled the .d.ts structure. This causes ngc to write incorrect imports for this bundle when compiling providers using MockBackend and other http testing classes. This change restructures the @angular/http/testing build a bit, modeling it after @angular/platform-browser-animations, and produces a FESM structure that has flat metadata. Fixes #15521. PR Close #16390
So what version will this be released in? |
@angular/http/testing used to publish a metadata structure which paralleled the .d.ts structure. This causes ngc to write incorrect imports for this bundle when compiling providers using MockBackend and other http testing classes. This change restructures the @angular/http/testing build a bit, modeling it after @angular/platform-browser-animations, and produces a FESM structure that has flat metadata. Fixes angular#15521.
Confirmed fix in 4.1.2. Thanks everyone! |
The issue is closed but i still get the error, i just upgraded to angular 4 (4.1.3) 2 days before, all the production code works fine, but all the tests are down, on reason is the MockBackend imported form '@angular/http/testing' is undefined. |
Same here, also webpack |
issue confirmed in ng 4.0.0, building --prod ERROR in ./src/$$_gendir/app/app.module.ngfactory.ts |
@angular/http/testing used to publish a metadata structure which paralleled the .d.ts structure. This causes ngc to write incorrect imports for this bundle when compiling providers using MockBackend and other http testing classes. This change restructures the @angular/http/testing build a bit, modeling it after @angular/platform-browser-animations, and produces a FESM structure that has flat metadata. Fixes angular#15521.
@angular/http/testing used to publish a metadata structure which paralleled the .d.ts structure. This causes ngc to write incorrect imports for this bundle when compiling providers using MockBackend and other http testing classes. This change restructures the @angular/http/testing build a bit, modeling it after @angular/platform-browser-animations, and produces a FESM structure that has flat metadata. Fixes angular#15521.
I have started to use Angular 5 but it still seems that the deep imports are not working yet. My IDE automatically predicts and add import to the related but to the deep level. By removing the deep link, the app started to work fine. For example, import { ElementRef } from '@angular/core'; // works fine but on the other hand, import { ElementRef } from '@angular/core/src/linker/element_ref'; // throws error. I made it to work just by removing the rest of the deep link and leaving only '@angular/core'; |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
Exception if adding MockBackend to a list of AppModule providers:
"Uncaught Error: Encountered undefined provider! Usually this means you have a circular dependencies (might be caused by using 'barrel' index.ts files."
This behavior since Angular 4.0 RC4/5. Mocking this way in 4.0 RC3 and earlier working just fine.
Exception in CompileMetadataResolver.prototype._getProvidersMetadata function
...
else if (provider === void 0) {
_this._reportError(syntaxError("Encountered undefined provider! Usually this means you have a circular dependencies (might be caused by using 'barrel' index.ts files."));
}
...
Expected behavior
FakeProvider is instantiated and MockBackend instance successfully injected.
Minimal reproduction of the problem with instructions
Add MockBackend to a list of AppModule providers.
...
import {MockBackend} from "@angular/http/testing";
...
providers: [
...
MockBackend, // <--
//FakeProvider,
//BaseRequestOptions
],
...
What is the motivation / use case for changing the behavior?
Mock an Http service for testing purpose and backend-less development
Please tell us about your environment:
Language: Typescript 2.2
Node (for AoT issues):
node --version
= 6.6.0The text was updated successfully, but these errors were encountered: