diff --git a/src/material/button/testing/button-harness.ts b/src/material/button/testing/button-harness.ts index 49edebcb25ce..7f3ba9eacff9 100644 --- a/src/material/button/testing/button-harness.ts +++ b/src/material/button/testing/button-harness.ts @@ -60,8 +60,9 @@ export class MatButtonHarness extends ContentContainerComponentHarness { .addOption('buttonType', options.buttonType, (harness, buttonType) => HarnessPredicate.stringMatches(harness.getType(), buttonType), ) - .addOption('iconName', options.iconName, (harness, iconName) => { - return harness.hasHarness(MatIconHarness.with({name: iconName})); + .addOption('iconName', options.iconName, async (harness, iconName) => { + const result = await harness.locatorForOptional(MatIconHarness.with({name: iconName}))(); + return result !== null; }); }