diff --git a/src/cdk/a11y/aria-describer/aria-describer.spec.ts b/src/cdk/a11y/aria-describer/aria-describer.spec.ts index 22e7dbea12c9..cec3d189d63f 100644 --- a/src/cdk/a11y/aria-describer/aria-describer.spec.ts +++ b/src/cdk/a11y/aria-describer/aria-describer.spec.ts @@ -20,6 +20,7 @@ describe('AriaDescriber', () => { fixture = TestBed.createComponent(TestApp); component = fixture.componentInstance; ariaDescriber = component.ariaDescriber; + fixture.detectChanges(); }); afterEach(() => { diff --git a/src/cdk/portal/portal.spec.ts b/src/cdk/portal/portal.spec.ts index 34606e7f9738..6b42ed759f81 100644 --- a/src/cdk/portal/portal.spec.ts +++ b/src/cdk/portal/portal.spec.ts @@ -563,8 +563,8 @@ class ArbitraryViewContainerRefComponent { }) class PortalTestApp { @ViewChildren(CdkPortal) portals: QueryList; - @ViewChild(CdkPortalOutlet) portalOutlet: CdkPortalOutlet; - @ViewChild('templateRef', { read: TemplateRef }) templateRef: TemplateRef; + @ViewChild(CdkPortalOutlet, {static: true}) portalOutlet: CdkPortalOutlet; + @ViewChild('templateRef', { read: TemplateRef , static: true}) templateRef: TemplateRef; selectedPortal: Portal|undefined; fruit: string = 'Banana'; @@ -600,7 +600,7 @@ class PortalTestApp { `, }) class UnboundPortalTestApp { - @ViewChild(CdkPortalOutlet) portalOutlet: CdkPortalOutlet; + @ViewChild(CdkPortalOutlet, {static: true}) portalOutlet: CdkPortalOutlet; } // Create a real (non-test) NgModule as a workaround for diff --git a/src/cdk/text-field/autofill.spec.ts b/src/cdk/text-field/autofill.spec.ts index 8b24ae5f524a..5879d374fcdf 100644 --- a/src/cdk/text-field/autofill.spec.ts +++ b/src/cdk/text-field/autofill.spec.ts @@ -217,9 +217,9 @@ describe('cdkAutofill', () => { }) class Inputs { // Cast to `any` so we can stub out some methods in the tests. - @ViewChild('input1') input1: ElementRef; - @ViewChild('input2') input2: ElementRef; - @ViewChild('input3') input3: ElementRef; + @ViewChild('input1', {static: true}) input1: ElementRef; + @ViewChild('input2', {static: true}) input2: ElementRef; + @ViewChild('input3', {static: true}) input3: ElementRef; } @Component({ diff --git a/src/lib/autocomplete/autocomplete.spec.ts b/src/lib/autocomplete/autocomplete.spec.ts index c23c3a069651..84d7a3551bc7 100644 --- a/src/lib/autocomplete/autocomplete.spec.ts +++ b/src/lib/autocomplete/autocomplete.spec.ts @@ -2352,7 +2352,7 @@ class SimpleAutocomplete implements OnDestroy { openedSpy = jasmine.createSpy('autocomplete opened spy'); closedSpy = jasmine.createSpy('autocomplete closed spy'); - @ViewChild(MatAutocompleteTrigger) trigger: MatAutocompleteTrigger; + @ViewChild(MatAutocompleteTrigger, {static: true}) trigger: MatAutocompleteTrigger; @ViewChild(MatAutocomplete) panel: MatAutocomplete; @ViewChild(MatFormField) formField: MatFormField; @ViewChildren(MatOption) options: QueryList; diff --git a/src/lib/bottom-sheet/bottom-sheet-container.ts b/src/lib/bottom-sheet/bottom-sheet-container.ts index 22848aa70b5e..ee815a814b7f 100644 --- a/src/lib/bottom-sheet/bottom-sheet-container.ts +++ b/src/lib/bottom-sheet/bottom-sheet-container.ts @@ -63,7 +63,7 @@ export class MatBottomSheetContainer extends BasePortalOutlet implements OnDestr private _breakpointSubscription: Subscription; /** The portal outlet inside of this container into which the content will be loaded. */ - @ViewChild(CdkPortalOutlet) _portalOutlet: CdkPortalOutlet; + @ViewChild(CdkPortalOutlet, {static: true}) _portalOutlet: CdkPortalOutlet; /** The state of the bottom sheet animations. */ _animationState: 'void' | 'visible' | 'hidden' = 'void'; diff --git a/src/lib/sidenav/drawer.spec.ts b/src/lib/sidenav/drawer.spec.ts index c8b57197475f..a45e8710a999 100644 --- a/src/lib/sidenav/drawer.spec.ts +++ b/src/lib/sidenav/drawer.spec.ts @@ -282,6 +282,8 @@ describe('MatDrawer', () => { let fixture = TestBed.createComponent(BasicTestApp); let drawer: MatDrawer = fixture.debugElement .query(By.directive(MatDrawer)).componentInstance; + fixture.detectChanges(); + let openButton = fixture.componentInstance.openButton.nativeElement; let closeButton = fixture.componentInstance.closeButton.nativeElement;