Issue 1:
Issues

Other Links

https://daveceddia.com/angular-2-errors/

http://www.bennadel.com/blog/3040-i-have-a-fundamental-misunderstanding-of-change-detection-in-angular-2-beta-8.htm

Issue 2:
I'm submitting a ...

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Here is my question on StackOverflow.

When using TestBed.createTestingModule(<TemplateModuleMetadata>) in my unit tests to test a service which dynamically creates and injects a component into the DOM, I am getting an error in the output of ng test as follows:

Error: No component factory found for TestDialogComponent. Did you add it to @NgModule.entryComponents?

No Component factory found for TestDialogComponent and

Did you add it to @NgModule.entryComponents

The 2nd point is the problem. I cannot add the TestDialogComponent to the Testing module, because entryComponents does not exist on the TemplateModuleMetadata object.

This is the following code in test_bed.d.ts, which shows that entryComponents does not exist in that type definition:

/**
* @experimental
*/
export declare type TestModuleMetadata = {
providers?: any[];
declarations?: any[];
imports?: any[];
schemas?: Array<SchemaMetadata | any[]>;
};

I have added the component to the entryComponents and declarations sections of the service's parent dialog.module.ts, but the tests still fail because the component hasn't actually been added to the testing module.

Expected behavior

The entryComponents property should be defined in the TestModuleMetadata definition. I could be wrong, but I assumed that all properties that are available in the standard angular 2 NgModule should also be available for use in the TestModuleMetadata object, so that testing modules mimic the structure of the actual application as accurately as possible. If one of my application modules relies on the ability to dynamically inject components, shouldn't I be able to replicate that functionality in my test module?

**Regarding my StackOverflow question, ** I've had a recommendation to simply add the Component I'd like to add to the entryComponents property to a test module, and then import that module.

Minimal reproduction of the problem with instructions

I've replicated the functionality of the portion of my app in question - View the reproduction plnkr here. Please Note: I'm not sure how to actually execute a jasmine test in Plnkr as I haven't used Plnkr much. If I had more time, I'd get it up and running, but hopefully my diagnostic description can suffice.

What is the motivation / use case for changing the behavior?

Having to create a whole separate module to import into my testing module doesn't align to the actual structure of my application's code. It's not clear why entryComponents is not included in the TestModuleMetadata, so it is unclear to me whether my stylistic approach to my application's structure is the problem or if it's just a simple omission to the TestModuleMetadata that can be easily implemented? To me, it seems as though the test environment should replicate my application environment as closely as possible, maybe some others agree?

Please tell us about your environment:

Angular CLI: v1.0.0-beta.32.3

Windows: v10

Sublime Text: v3

NPM: v3.10.10

Node: v6.9.5

Typescript: ~2.0.10

Karma: 1.2.0

Angular version: 2.4.7

Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Chrome (*(Karma-chrome-launcher:** v^2.0.0)

Language: [all | TypeScript X.X | ES6/7 | ES5]

Typescript

ES6

Node (for AoT issues): node --version =

Node: v6.9.5