-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
No provider for NgModel when running tests #929
Comments
The Ng2BootstrapModule includes all components (e.g. Datapicker). Import only the modules you need (e.g. DropdownModule, AlarmModule...) |
Doesn't work either. It shouldn't throw an error when everything is included though. |
I removed all except the PaginationComponent which I'm using in the component I'm testing. The error changes to:
|
As far as I remember test requiring additional ngModel injection, please take a look on test for corresponding components |
The buttons, pagination, rating and typeahead modules use |
Any idea for a workaround? |
@valorkin I hope this PR helps? @binarious can you give me a small example so I can test it? |
@Martin-Wegner Not really. I just have complex app tests, but I'm already checking out your branch to test it locally. |
Unfortunately I'm getting the same error. |
Perhaps you use |
Pretty sure that's not the case. I'm using a |
In every component? You mean in every module or? |
Sorry, right. In every module. |
Do you have gitter? We may can figure that out there without spamming this issue? |
No I don't and I must go now, sorry :( |
Ok, I'll create a simple example project later. |
I had a very similar problem yesterday (exactly the same error message) and was able to fix it similar to what @Martin-Wegner suggested: adding the FormsModule as import to the affected module. |
@binarious are you sure, that you checked out my fork of the ng2-bootstrap repository? |
I have improved my PR #931 |
@Martin-Wegner I've created a fork of your development branch without the
Files and changes were in my |
OK good to know but I think we should keep the PR:
|
@Martin-Wegner Do you mind to join https://gitter.im/valor-software/ng2-bootstrap/ and message me there? |
May be slack? :) On Tue, Sep 6, 2016, 11:35 binarious notifications@github.com wrote:
|
I was able to create a repository to reproduce this error: https://github.com/binarious/ng2-bootstrap-testing Hope that helps. |
Something it totally weird... The test from @binarious fails, if the
pointed to the template of PopupContainerComponent. This component is not declared inside the |
@valorkin The PR #931 doesn't fix this issue. Please take a look at https://github.com/binarious/ng2-bootstrap-testing (+ README.md). |
@valorkin I reopen this issue due to I wrote in my last comment... |
@valorkin please have a look at #943 @binarious your about template is using |
Can confirm. All you need is to include DatepickerModule in any |
Btw I was testing it with @Martin-Wegner 's #943 changes |
There is no current documentation available for Angular 2 tesing: https://angular.io/docs/ts/latest/guide/testing.html Therefore I have no idea how a spec-file should look like for testing components from modules... |
I made a repo with detailed steps how to reproduce the error, check it out: Martin is right about the lack of documentation for testing so I used semi-official angular-cli to set up the project, let's hope doing so excludes set-up related problems from the probable cause options. I'll try to narrow it down tomorrow. So far feels like ng2-bootstrap is innocent since the code looks fine and it works just fine in the browser and the test environment is somehow different which shouldn't be the case in a perfect world. Well, the world isn't perfect... |
@Igonato any news on this? |
@Martin-Wegner not yet. Only now got some time |
FYI: Same problem with Angular RC7. |
#963 should fix this
|
@Igonato thank you so much! Did you report this Issue to the Angular 2 team? |
Not yet. I'll play with it a bit more on the weekend, I want to reproduce it with minimum code before submitting it |
May be it related to: view providers not pushed to child components? On Wed, Sep 14, 2016, 12:05 Ignat Shining notifications@github.com wrote:
|
@valorkin datepicker component isn't a child, it's top level in the datepicker module where forms module is imported, right? |
When you write a test you are creating a wrapper component, so this wrapper On Wed, Sep 14, 2016, 13:42 Ignat Shining notifications@github.com wrote:
|
Also, viewProviders are component-only anyway, you can't define them in NgModule, that's what imports are for, correct? No, this is the thing, I don't need to add datepicker to any of my components, adding datepicker module to imports of my module is enough for the failure to happen |
Can you try to add ng model stuff to imports (providers)? On Wed, Sep 14, 2016, 13:49 Ignat Shining notifications@github.com wrote:
|
I did, pretty much in all places you can think of :) same error happens |
@Igonato I can feel your pain, because me did too :) |
should be fixed with #963 |
…esent (valor-software#931) * try to fix valor-software#929 by importing FormsModule because the selectors use [ngModel] * export FormsModule in all modules which use ngModel selector binding because every template which uses such a module would anyway import FormsModul which is now no longer necessary fixes valor-software#929
…esent (valor-software#931) * try to fix valor-software#929 by importing FormsModule because the selectors use [ngModel] * export FormsModule in all modules which use ngModel selector binding because every template which uses such a module would anyway import FormsModul which is now no longer necessary fixes valor-software#929
I've moved to RC6. Dev and prod are running well, but when running tests I get:
I'm not using the datepicker. I've just imported
Ng2BootstrapModule
in my Module.The text was updated successfully, but these errors were encountered: