{"record":{"id":"425ecebf64ac3ce9","repo":"angular/components","slug":"cannot-find-calendar-cell-matching-filter-json-s","errorCode":null,"errorMessage":"Cannot find calendar cell matching filter ${JSON.stringify(filter)}","messagePattern":"Cannot find calendar cell matching filter (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/material/datepicker/testing/calendar-harness.ts","lineNumber":89,"sourceCode":"  }\n\n  /**\n   * Goes to the previous page of the current view\n   * (e.g. previous month when inside the month view).\n   */\n  async previous(): Promise<void> {\n    return (await this.locatorFor('.mat-calendar-previous-button')()).click();\n  }\n\n  /**\n   * Selects a cell in the current calendar view.\n   * @param filter An optional filter to apply to the cells. The first cell matching the filter\n   *     will be selected.\n   */\n  async selectCell(filter: CalendarCellHarnessFilters = {}): Promise<void> {\n    const cells = await this.getCells(filter);\n    if (!cells.length) {\n      throw Error(`Cannot find calendar cell matching filter ${JSON.stringify(filter)}`);\n    }\n    await cells[0].select();\n  }\n}\n","sourceCodeStart":71,"sourceCodeEnd":94,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/material/datepicker/testing/calendar-harness.ts#L71-L94","documentation":"The MatCalendarHarness test helper's selectCell(filter) locates calendar cells matching the given filters and throws a plain Error when no cell matches. This is a harness lookup failure, not a runtime application error.","triggerScenarios":"Calling harness.selectCell({text: '15'}) (or any CalendarCellHarnessFilters) when the calendar's current view contains no cell matching the filter — wrong day number, wrong month/year displayed, or an empty filter on a disabled calendar.","commonSituations":"Testing a datepicker where the test navigated to the wrong month; cells rendered but filter text mismatches displayed value (e.g. locale-formatted numbers); attempting to select a cell before the calendar is open/rendered.","solutions":["Ensure the calendar is open and displaying the expected view before calling selectCell","Make the filter specific but correct, e.g. selectCell({text: '15'}) after navigating to the right month via harness APIs (previous/next buttons or setDate)","Use getCells() first and log available cells to debug filter mismatches","Await rendering with harness.waitForTasksOutsideAngular() or MatCalendarHarness readiness checks"],"exampleFix":"// before\nawait calendar.selectCell({text: '31'}); // wrong month in view\n// after\nawait calendar.next(); // navigate to the month containing the 31st\nawait calendar.selectCell({text: '31'});","handlingStrategy":"type-guard","validationCode":"const cells = await calendar.getCells(filter);\nif (!cells.length) {\n  console.warn('No cell matches filter; check month/year in view');\n  return;\n}\nawait cells[0].select();","typeGuard":"function hasCells(cells: MatCalendarCellHarness[]): cells is [MatCalendarCellHarness, ...MatCalendarCellHarness[]] {\n  return cells.length > 0;\n}","tryCatchPattern":"try {\n  await calendar.selectCell({text: '15'});\n} catch (e) {\n  if ((e as Error).message.includes('Cannot find calendar cell')) {\n    // navigate calendar view and retry\n  }\n}","preventionTips":["Navigate to the correct month/year before selecting cells","Use getCells() to inspect available cells when debugging filters","Account for locale formatting in cell text when writing filters"],"tags":["angular","material","testing","cdk-harness","datepicker"],"backgroundTag":"harness-element-not-found","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}