{"record":{"id":"ada9d88c88a2668b","repo":"angular/components","slug":"select-does-not-have-options-matching-the-specifie-ada9d8","errorCode":null,"errorMessage":"Select does not have options matching the specified filter","messagePattern":"Select does not have options matching the specified filter","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/material/select/testing/select-harness.ts","lineNumber":140,"sourceCode":"      const trigger = await this.locatorFor(`.${this._prefix}-select-trigger`)();\n      return trigger.click();\n    }\n  }\n\n  /**\n   * Clicks the options that match the passed-in filter. If the select is in multi-selection\n   * mode all options will be clicked, otherwise the harness will pick the first matching option.\n   */\n  async clickOptions(filter?: OptionHarnessFilters): Promise<void> {\n    await this.open();\n\n    const [isMultiple, options] = await parallel(() => [\n      this.isMultiple(),\n      this.getOptions(filter),\n    ]);\n\n    if (options.length === 0) {\n      throw Error('Select does not have options matching the specified filter');\n    }\n\n    if (isMultiple) {\n      await parallel(() => options.map(option => option.click()));\n    } else {\n      await options[0].click();\n    }\n  }\n\n  /** Closes the select's panel. */\n  async close(): Promise<void> {\n    if (await this.isOpen()) {\n      // This is the most consistent way that works both in both single and multi-select modes,\n      // but it assumes that only one overlay is open at a time. We should be able to make it\n      // a bit more precise after #16645 where we can dispatch an ESCAPE press to the host instead.\n      return (await this._backdrop()).click();\n    }\n  }","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/material/select/testing/select-harness.ts#L122-L158","documentation":"The Material select test harness throws this when `clickOptions(filter)` finds no options matching the given filter text. It fetches options via `getOptions(filter)` and fails fast when the result is empty instead of clicking nothing. It signals the harness query did not match any rendered option.","triggerScenarios":"`await harness.clickOptions({text: 'Foo'})` where no option's text matches 'Foo', the panel isn't open so options aren't rendered, or the filter string's case/whitespace differs from the option text.","commonSituations":"Test data renamed so the expected option text changed; forgetting to call `open()` before interacting; using partially matched text against options that render formatted values.","solutions":["Call `await select.open()` before `clickOptions` so options are rendered in the DOM.","Verify the filter text exactly matches the visible option text (or use a regex/substring that matches).","Assert `await harness.getOptions()` returns the expected options before clicking.","Check that the correct mat-select harness instance is being used (right control on the page)."],"exampleFix":"// before\nconst harness = await loader.getHarness(MatSelectHarness.with({selector: '#city'}));\nawait harness.clickOptions({text: 'New Yrok'});\n// after\nawait harness.open();\nawait harness.clickOptions({text: 'New York'});","handlingStrategy":"validation","validationCode":"await select.open();\nconst opts = await select.getOptions({text: 'New York'});\nif (opts.length === 0) throw new Error('Expected option New York not found');\nawait select.clickOptions({text: 'New York'});","typeGuard":"null","tryCatchPattern":"try {\n  await harness.clickOptions({text: 'New York'});\n} catch (e) {\n  if ((e as Error).message.includes('does not have options')) {\n    throw new Error('Test fixture missing expected option: verify template/data');\n  }\n  throw e;\n}","preventionTips":["Always call `open()` on the select harness before clicking options.","Match option text against the rendered label, not the underlying value.","Print `await harness.getOptionsText()` in failing tests to see available options."],"tags":["angular","material","testing","test-harness"],"backgroundTag":"harness-element-not-found","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}