How to find proper harness by id?

Discussão em 'Angular' iniciado por Budda, Dezembro 23, 2024.

  1. Budda

    Budda Guest

    In my component tests, I need to find a proper Input element.

    I can find all of them by doing:

    let loader: HarnessLoader = TestbedHarnessEnvironment.loader(fixture);
    const inputs = await loader.getAllHarnesses(MatInputHarness);
    expect(inputs).toBeTruthy();


    But how can I find a proper input in the array?

    Deep inside, each 'input' has the id because I see it:

    console.log(`id: ${await inputs[0].getId()}`);


    outputs the proper id.

    Do I have to go in a loop through the whole list of inputs to check the id of every element? And call 'await' for each of those?

    I'm afraid this might be too computational-heavy. Also, this just smells wrong.

    How do I get a required input element by id?

    Continue reading...

Compartilhe esta Página