DEV Community

John Peters
John Peters

Posted on • Updated on

Failed: Type X is part of the declarations of 2 modules: AppModule and DynamicTestModule

When writing Jasmine tests, the message above is common. The failed test looks like this:

failed test case

Root Cause

AppModule already declares the component under test!

rootcause

Resolve

Remove the declaration in the jasmine file; shown below:
Same test as shown above, with missing 2nd declaration.

solution

Easy right?

JWP2019

Top comments (1)

Collapse
 
mikel_hamer_50f46faf752f0 profile image
Mikel Hamer

OMG THANK YOU SO MUCH