I can get the input value of the form field above by using this query in my spec file:
expect(findEl(fixture, "mail").nativeElement.value).toBe('email@mail.com');
<mat-form-field fxFlex="auto">
<mat-label>E-Mail</mat-label>
<input
matInput
required
type="email"
readonly
autocomplete="off"
data-testid="mail"
formControlName="mail"
/>
<mat-icon
matSuffix
mat-icon-button
>email</mat-icon
>
</mat-form-field>
But when I try to do the same within a mat-select form field, value returns undefined
<mat-form-field fxFlex="auto">
<mat-label>Sexo</mat-label>
<mat-select
required
data-testid="genderType"
formControlName="genderType"
>
<mat-option>--</mat-option>
<mat-option *ngFor="let gender of genders" [value]="gender.id">
{{ gender.name }}
</mat-option>
</mat-select>
<mat-icon
matSuffix
mat-icon-button
>wc</mat-icon
>
</mat-form-field>
expect(findEl(fixture, "genderType").nativeElement.value).toBe(1);
//Error: Expected undefined to be 1.
How can I get the selected value or text of a mat-select?