Skip to content

Exclude componentDeclarations from TestingModule #27

Closed
@szabototo89

Description

@szabototo89

For the sake of simplicity, there was a change in the render usage and we don't need to specify the tested component in the declarations within the RenderOptions object. However most of the time the component is declared in a NgModule, because of many dependencies and it also make tests more resilience.

With the current mechanism we're getting these errors:

Error: Type XYZComponent is part of the declarations of 2 modules: XYZModule and DynamicTestModule! Please consider moving XYZComponent to a higher module that imports XYZModule and DynamicTestModule. You can also create a new NgModule that exports and includes XYZComponent then import that NgModule in XYZModule and DynamicTestModule.

I could cherry-pick every dependency of the component and specify it, but it would make the tests more brittle. If it's possible I would like to avoid it.

Related code: https://github.com/testing-library/angular-testing-library/blob/master/projects/testing-library/src/lib/testing-library.ts#L38

Could you provide a configuration option to exclude componentDeclarations from TestingModule?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreleased

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions