{"record":{"id":"13ebe6585659be60","repo":"angular/components","slug":"could-not-find-tab-matching-filters-json-string","errorCode":null,"errorMessage":"Could not find tab matching filters: ${JSON.stringify(filters)}","messagePattern":"Could not find tab matching filters: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/aria/tabs/testing/tabs-harness.ts","lineNumber":109,"sourceCode":"    return new HarnessPredicate(TabsHarness, options);\n  }\n\n  /** Gets all tabs inside the tabs container. */\n  async getTabs(filters: TabHarnessFilters = {}): Promise<TabHarness[]> {\n    return await this.locatorForAll(TabHarness.with(filters))();\n  }\n\n  /** Gets the currently selected tab. */\n  async getSelectedTab(): Promise<TabHarness | null> {\n    const tabs = await this.getTabs({selected: true});\n    return tabs.length > 0 ? tabs[0] : null;\n  }\n\n  /** Selects a tab matching the given filters. */\n  async selectTab(filters: TabHarnessFilters = {}): Promise<void> {\n    const tabs = await this.getTabs(filters);\n    if (tabs.length === 0) {\n      throw new Error(`Could not find tab matching filters: ${JSON.stringify(filters)}`);\n    }\n    await tabs[0].select();\n  }\n}\n","sourceCodeStart":91,"sourceCodeEnd":114,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/aria/tabs/testing/tabs-harness.ts#L91-L114","documentation":"selectTab is a convenience method on the tabs harness that finds tabs matching TabHarnessFilters and clicks the first match. If zero tabs match the filters, there is nothing to select, so it throws with the serialized filters.","triggerScenarios":"Calling harness.selectTab({text: 'Settings'}) (or label/other filters) where no rendered tab matches; tabs not yet rendered; filter text mismatching due to whitespace/case; wrong harness instance (another tab group).","commonSituations":"Typo or renamed tab label after a UI change; asserting on tabs inside a lazy-rendered tab group before change detection runs; using a filter field not supported/overridden by the tab harness.","solutions":["Verify the filter matches a rendered tab (await getTabs() first and inspect length).","Loosen or correct the filter (e.g. text substring, remove extra filters).","Ensure the tab group is rendered/initialized before selecting (flush change detection, await whenStable).","Guard with a check: const tabs = await harness.getTabs(filters); if (tabs.length) await tabs[0].select();","Use getTabsAtIndex/selectedTab APIs when you want index-based or current-tab behavior."],"exampleFix":"// before\nawait harness.selectTab({text: 'Setings'});\n// after\nconst tabs = await harness.getTabs();\nconst target = tabs.find(async t => (await t.getLabel()) === 'Settings');\nif (!target) throw new Error('Settings tab not rendered');\nawait target.select();","handlingStrategy":"validation","validationCode":"const tabs = await harness.getTabs(filters);\nif (tabs.length === 0) throw new Error(`No tab matches ${JSON.stringify(filters)}`);\nawait tabs[0].select();","typeGuard":null,"tryCatchPattern":"try {\n  await harness.selectTab({text: 'Settings'});\n} catch (e) {\n  if ((e as Error).message.startsWith('Could not find tab matching filters')) {\n    console.warn('Tab missing; rendering may be lazy');\n  } else throw e;\n}","preventionTips":["Fetch getTabs() and assert count before selecting.","Keep tab labels in constants shared between templates and tests.","Flush change detection/await stability before interacting with lazy tab groups."],"tags":["angular","cdk-harness","testing","tabs"],"backgroundTag":"harness-element-not-found","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}