Skip to content

TestComponentBuilder needs common directives referenced in @View #6195

Closed

Description

@matthewdenobrega

Currently the common directives (CORE_DIRECTIVES and FORM_DIRECTIVES) are included automatically and do not need to be manually referenced in a component's @view annotation. However this is not the case for the TestComponentBuilder, which fails to build the component if the component uses unreferenced common directives. An example error message is:

{"message":"Template parse errors: Can't bind to 'ngFormControl' since it isn't a known native property...

It's possible to add these references in to the component definition, but ideally the TCB should be able to build whatever Angular builds normally. Also the way the TCB handles errors (calling the onrejected callback of the promise, which I seldom see anyone binding to) means that tests can be regarded as passing if the component fails to build:

tcb.createAsync(testComponent).then((fixture: ComponentFixture) => {
    expect(true).toBe(false)
})

Will pass if the TCB fails to create the component.

So proposed solution would be to make the common directives available to the TCB.

Activity

  1. ericmartinezr commented on Dec 31, 2015

    @ericmartinezr
    Contributor

    There's a fix for this in #5975

  2. pkozlowski-opensource commented on Dec 31, 2015

    @pkozlowski-opensource
    Member

    Closing as duplicate of #5433

  3. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  4. locked and limited conversation to collaborators on Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions