From 306a453b0ff276ba4f525c6df894987f5ced8e9e Mon Sep 17 00:00:00 2001 From: Tim Deschryver Date: Sat, 16 Jun 2018 11:39:10 +0200 Subject: [PATCH] fix: detectchanges on type component --- .../src/lib/ngx-testing-library.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/projects/ngx-testing-library/src/lib/ngx-testing-library.ts b/projects/ngx-testing-library/src/lib/ngx-testing-library.ts index 63c5f0e5..36f9f2a0 100644 --- a/projects/ngx-testing-library/src/lib/ngx-testing-library.ts +++ b/projects/ngx-testing-library/src/lib/ngx-testing-library.ts @@ -15,10 +15,10 @@ export async function createComponent( { detectChanges = true, declarations = [], providers = [], imports = [], schemas = [] }: Options, ): Promise { const isTemplate = typeof templateOrComponent === 'string'; - const extraDeclarations = isTemplate ? [TestComponent] : []; + const testComponent = isTemplate ? [TestComponent] : []; TestBed.configureTestingModule({ - declarations: [...declarations, ...extraDeclarations], + declarations: [...declarations, ...testComponent], providers: [...providers], imports: [...imports], schemas: [...schemas], @@ -37,9 +37,6 @@ export async function createComponent( let fixture; if (isTemplate) { fixture = TestBed.createComponent(TestComponent); - if (detectChanges) { - fixture.detectChanges(); - } } else { const { component, parameters = [] } = >templateOrComponent; fixture = TestBed.createComponent(component); @@ -48,6 +45,10 @@ export async function createComponent( } } + if (detectChanges) { + fixture.detectChanges(); + } + // Currently this isn't perfect because the typings from dom-testing-library are for TS 2.8 return { fixture,