{"record":{"id":"0a76b79cf086b0d2","repo":"angular/components","slug":"cannot-find-chip-matching-filter-json-stringify","errorCode":null,"errorMessage":"Cannot find chip matching filter ${JSON.stringify(filter)}","messagePattern":"Cannot find chip matching filter (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/material/chips/testing/chip-listbox-harness.ts","lineNumber":78,"sourceCode":"  }\n\n  /**\n   * Gets the list of chips inside the chip list.\n   * @param filter Optionally filters which chips are included.\n   */\n  async getChips(filter: ChipOptionHarnessFilters = {}): Promise<MatChipOptionHarness[]> {\n    return this.locatorForAll(MatChipOptionHarness.with(filter))();\n  }\n\n  /**\n   * Selects a chip inside the chip list.\n   * @param filter An optional filter to apply to the child chips.\n   *    All the chips matching the filter will be selected.\n   */\n  async selectChips(filter: ChipOptionHarnessFilters = {}): Promise<void> {\n    const chips = await this.getChips(filter);\n    if (!chips.length) {\n      throw Error(`Cannot find chip matching filter ${JSON.stringify(filter)}`);\n    }\n    await parallel(() => chips.map(chip => chip.select()));\n  }\n}\n","sourceCodeStart":60,"sourceCodeEnd":83,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/material/chips/testing/chip-listbox-harness.ts#L60-L83","documentation":"The MatChipListboxHarness's selectChips test helper resolves child chips matching the given harness filter and throws if none are found. This is a fail-fast guard so tests don't silently no-op when the expected chips are absent.","triggerScenarios":"Calling harness.selectChips({...}) with a filter (e.g. by text) that matches no rendered chip, or calling it when the chip list is empty/not yet rendered.","commonSituations":"Test runs before Angular has finished rendering (missing await for render/fixtures), wrong chip label text or case, chips filtered out by user input, or testing against a chip-grid instead of chip-listbox.","solutions":["Verify the filter (text etc.) matches a rendered chip exactly.","Await rendering before querying (await fixture.whenStable() / harness waitForTasksOutsideAngular patterns).","First list chips via getChips() and assert the set before selecting.","Confirm the harness used corresponds to the actual component (chip-listbox vs chip-grid harness)."],"exampleFix":"// before\nawait harness.selectChips({ text: 'Angular 13' });\n// after\nconst chips = await harness.getChips();\nif (!chips.some(c => c.getText().then(t => t.includes('Angular')))) {\n  fail('Expected chip not rendered');\n}\nawait harness.selectChips({ text: 'Angular' });","handlingStrategy":"validation","validationCode":"const chips = await harness.getChips(filter);\nif (!chips.length) {\n  fail(`No chips match filter ${JSON.stringify(filter)}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await harness.selectChips({ text: 'Expected' });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Cannot find chip matching filter')) {\n    const all = await harness.getChips();\n    fail(`Chips available: ${JSON.stringify(await Promise.all(all.map(c => c.getText())))}`);\n  } else { throw e; }\n}","preventionTips":["Await fixture.whenStable() before harness interactions.","Assert chip list contents with getChips() before selecting.","Keep chip labels in constants shared between template and tests."],"tags":["angular-material","component-harness","testing","chip"],"backgroundTag":"harness-element-not-found","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}