Skip to content

How test mat-checkbox? #362

Closed
Closed
@sinkz

Description

@sinkz

I'm trying to test a component that has a mat-checkbox. But every time I simulate the click on the checkbox and make the assert the expected result is not the one returned.

Ex:

const checkboxes = await screen.getAllByTestId('checkbox-benefit');
const checkbox = checkboxes[0];
expect(checkbox).not.toBeChecked()

userEvent.click(checkbox);
component.fixture.detectChanges();
expect(checkbox).toBeChecked() // Failed, mark false

Any example for this?

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