0

Hi I am trying to write a unit test using the TestComponentBuilder for an angular 2 app. When I call fixture.detectChanges() I get a no value accessor for 'settingName' error. Anybody have an idea why this would happen?

Here is a repo to see the error. It uses angular-cli https://github.com/bluefalcon/angular2-model-form-spec

here is the error: ORIGINAL EXCEPTION: No value accessor for 'settingName' ORIGINAL STACKTRACE: Error: No value accessor for 'settingName' at new BaseException (http://localhost:9876/base/dist/vendor/@angular/forms/src/facade/exceptions.js:27:23) at _throwError (http://localhost:9876/base/dist/vendor/@angular/forms/src/directives/shared.js:55:11) at Object.setUpControl (http://localhost:9876/base/dist/vendor/@angular/forms/src/directives/shared.js:30:9) at FormGroupDirective.addControl (http://localhost:9876/base/dist/vendor/@angular/forms/src/directives/reactive_directives/form_group_directive.js:71:18) at FormControlName.ngOnChanges (http://localhost:9876/base/dist/vendor/@angular/forms/src/directives/reactive_directives/form_control_name.js:39:32) at DebugAppView._View_SettingComponent0.detectChangesInternal (SettingComponent.template.js:198:55) at DebugAppView.AppView.detectChanges (http://localhost:9876/base/dist/vendor/@angular/core/src/linker/view.js:243:14) at DebugAppView.detectChanges (http://localhost:9876/base/dist/vendor/@angular/core/src/linker/view.js:348:44) at DebugAppView.AppView.detectViewChildrenChanges (http://localhost:9876/base/dist/vendor/@angular/core/src/linker/view.js:269:19) at DebugAppView._View_SettingComponent_Host0.detectChangesInternal (SettingComponent.template.js:37:8) at DebugAppView.AppView.detectChanges (http://localhost:9876/base/dist/vendor/@angular/core/src/linker/view.js:243:14) at DebugAppView.detectChanges (http://localhost:9876/base/dist/vendor/@angular/core/src/linker/view.js:348:44) at ViewRef_.detectChanges (http://localhost:9876/base/dist/vendor/@angular/core/src/linker/view_ref.js:131:65) at ComponentFixture._tick (http://localhost:9876/base/dist/vendor/@angular/core/testing/component_fixture.js:63:32) at eval (http://localhost:9876/base/dist/vendor/@angular/core/testing/component_fixture.js:77:49) at ZoneDelegate.invoke (http://localhost:9876/base/dist/vendor/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:323:29) at AsyncTestZoneSpec.onInvoke (http://localhost:9876/base/dist/vendor/zone.js/dist/async-test.js?8f51e44ce2093ec5167bc06760f15344db17d094:76:44) at ZoneDelegate.invoke (http://localhost:9876/base/dist/vendor/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:322:35) at Object.onInvoke (http://localhost:9876/base/dist/vendor/@angular/core/src/zone/ng_zone_impl.js:53:41) at ZoneDelegate.invoke (http://localhost:9876/base/dist/vendor/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:322:35) at Zone.run (http://localhost:9876/base/dist/vendor/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:216:44) at NgZoneImpl.runInner (http://localhost:9876/base/dist/vendor/@angular/core/src/zone/ng_zone_impl.js:84:71) at NgZone.run (http://localhost:9876/base/dist/vendor/@angular/core/src/zone/ng_zone.js:235:66) at ComponentFixture.detectChanges (http://localhost:9876/base/dist/vendor/@angular/core/testing/component_fixture.js:77:25) at eval (http://localhost:9876/base/dist/app/setting/setting.component.spec.js:31:29) at F (http://localhost:9876/base/dist/vendor/systemjs/dist/system-polyfills.js?a9f0c97e865a53da4c067b98cf2e65a23b2f0608:4:7484) at H (http://localhost:9876/base/dist/vendor/systemjs/dist/system-polyfills.js?a9f0c97e865a53da4c067b98cf2e65a23b2f0608:4:7116) at q.when (http://localhost:9876/base/dist/vendor/systemjs/dist/system-polyfills.js?a9f0c97e865a53da4c067b98cf2e65a23b2f0608:4:10790) at b.run (http://localhost:9876/base/dist/vendor/systemjs/dist/system-polyfills.js?a9f0c97e865a53da4c067b98cf2e65a23b2f0608:4:9826) at t._drain (http://localhost:9876/base/dist/vendor/systemjs/dist/system-polyfills.js?a9f0c97e865a53da4c067b98cf2e65a23b2f0608:4:1744) at drain (http://localhost:9876/base/dist/vendor/systemjs/dist/system-polyfills.js?a9f0c97e865a53da4c067b98cf2e65a23b2f0608:4:1398) at MutationObserver.e (http://localhost:9876/base/dist/vendor/systemjs/dist/system-polyfills.js?a9f0c97e865a53da4c067b98cf2e65a23b2f0608:4:3319) at ZoneDelegate.invoke (http://localhost:9876/base/dist/vendor/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:323:29) at Zone.runGuarded (http://localhost:9876/base/dist/vendor/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:230:48) at MutationObserver. (http://localhost:9876/base/dist/vendor/zone.js/dist/zone.js?8b9c8d0a7e549abe9edec8da5a095f206d206277:206:30) ERROR CONTEXT: [object Object]"

2
  • beforeEach was removed from @angular/core/testing and it should be used as part of the built in Jasmine functions as mentioned here: github.com/angular/angular/pull/9564. However I am not sure that this is what causes the issue. Commented Jul 12, 2016 at 8:15
  • thanks @knikolov for pointing that out. I went ahead and fixed that. Yes you are correct, that did not resolve the issue, but prevented an issue down the road. Thanks. Commented Jul 12, 2016 at 15:17

1 Answer 1

0

Finally figured it out. I love it when the answer is simple. Needed to add disableDeprecatedForms() and provideForms() to the addProviders([]). Oh yeah don't forget the '()'

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.