Skip to content

help(mat-select): standalone comp testing error TypeError: element.animate is not a function #25938

@GeorgeKnap

Description

@GeorgeKnap

What are you trying to do?

I'm trying to have a test of a standalone component which contains mat-select.
However, no matter what I do I face an error TypeError: element.animate is not a function
This is my test:

  it('should be able to open and close a select', async () => {
    const select = await loader.getHarness(MatSelectHarness);
    expect(await select.isOpen()).toBe(false);
    await select.open();
    expect(await select.isOpen()).toBe(true);
    await select.close();
    expect(await select.isOpen()).toBe(false);
  });

What troubleshooting steps have you tried?

I tried to provide provideNoopAnimations() in providers of TestBed.configureTestingModule() and also in providers of TestBed.overrideComponent() but it does not have any effect

Reproduction

Steps to reproduce:
1.
2.

Environment

  • Angular: 14.2.3
  • CDK/Material: 14.2.2
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Win11

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue needs to be triaged by the teamtroubleshootingThis issue is not reporting an issue, but just asking for help

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions