Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript - Cannot find name 'By'

I have a problem with my Angular unit tests in Karma and TypeScript.

With the code

fixture.debugElement.query(By.css('.mat-select-trigger')).nativeElement.click();

I get an error [ts] Cannot find name 'By'.

What am I missing here? The only available import is import { by } from 'protractor' but I believe it's not that.

like image 489
Dandy Avatar asked Sep 21 '18 13:09

Dandy


1 Answers

For import the "By". You have need use platform-browser, like this :

import {By} from "@angular/platform-browser";
like image 86
xRdev_38 Avatar answered Oct 23 '22 07:10

xRdev_38