Skip to content

Angular Material - Verify Form and Display / Text Value of a Select Box #275

Closed
@mleimer

Description

@mleimer

Testing an Angular Material Select-Box https://material.angular.io/components/select/examples#select-custom-trigger appears to be rather cumbersome at this stage.

Based on 04-forms-with-material

..verifying if a Angular Material Select-Box has a pre-set form value requires one to do:
expect((fixture.componentInstance as MaterialFormsComponent).form?.get('color')?.value).toBe('B');

..verifying its pre-set display/text-value requires on to do something like:
detectChanges();
expect(colorControl).toHaveTextContent('Blue');`

It would be great if we could achieve easier solutions where:

  • the value can be verified through toHaveFormValues or toHaveValue on its control
  • any display value / text can be verified without having to click on a native element and forcing detectChanges()

Am I maybe missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions