{"record":{"id":"7af8149a627e4003","repo":"angular/components","slug":"matdatepickeractions-does-not-have-name-button","errorCode":null,"errorMessage":"MatDatepickerActions does not have ${name} button","messagePattern":"MatDatepickerActions does not have (.+?) button","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/material/datepicker/testing/datepicker-actions-harness.ts","lineNumber":53,"sourceCode":"  ): HarnessPredicate<MatDatepickerActionsHarness> {\n    return new HarnessPredicate(MatDatepickerActionsHarness, options);\n  }\n\n  /** Applies the current selection. */\n  apply(): Promise<void> {\n    return this._clickAction('apply', this._applyLocator);\n  }\n\n  /** Cancels the current selection. */\n  cancel(): Promise<void> {\n    return this._clickAction('cancel', this._cancelLocator);\n  }\n\n  private async _clickAction(name: string, locator: () => Promise<TestElement | null>) {\n    const button = await locator();\n\n    if (!button) {\n      throw new Error(`MatDatepickerActions does not have ${name} button`);\n    }\n\n    await button.click();\n  }\n}\n","sourceCodeStart":35,"sourceCodeEnd":59,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/material/datepicker/testing/datepicker-actions-harness.ts#L35-L59","documentation":"The MatDatepickerActions testing harness _clickAction helper throws when the locator finds no matching actions button in the datepicker. apply() and cancel() call it with locators for the confirm/cancel buttons; if the developer never rendered a mat-datepicker-actions element (or lacks the specific button), the harness cannot click anything. It signals the fixture under test does not expose the expected action button.","triggerScenarios":"Calling harness.clickActions('apply') or harness.cancel() (via MatDatepickerActionsHarness methods) when the opened datepicker content has no mat-datepicker-actions block, or no button matching the harness locator; actions rendered outside the queried datepicker; harness connected to the wrong datepicker instance.","commonSituations":"Copy-pasting harness tests from an example while the component template omits mat-datepicker-actions; forgetting to open the datepicker before querying actions; conditional rendering of actions; typos so the button isn't inside the actions container.","solutions":["Add <mat-datepicker-actions> with <button mat-button matDatepickerCancel> and <button mat-button matDatepickerApply> inside the date input's mat-datepicker in the fixture template","Ensure the datepicker is opened before querying/clicking actions","Verify the harness is connected to the correct datepicker harness instance","Check the fixture rendered the actions synchronously (wait for harness stability)"],"exampleFix":"// before (template)\n<mat-datepicker #dp></mat-datepicker>\n// after\n<mat-datepicker #dp>\n  <mat-datepicker-actions>\n    <button mat-button matDatepickerCancel>Cancel</button>\n    <button mat-button matDatepickerApply>Apply</button>\n  </mat-datepicker-actions>\n</mat-datepicker>","handlingStrategy":"validation","validationCode":"const actions = await datepickerHarness.getActions();\nif (!actions) {\n  throw new Error('Fixture template must include <mat-datepicker-actions> for this test');\n}\nawait actions.clickActions({ applyLabel: 'Apply' });","typeGuard":null,"tryCatchPattern":"try {\n  await actionsHarness.clickActions('apply');\n} catch (e) {\n  if (String(e?.message).startsWith('MatDatepickerActions does not have')) {\n    fail('Add <mat-datepicker-actions> with cancel/apply buttons to the fixture template');\n  }\n  throw e;\n}","preventionTips":["Always include <mat-datepicker-actions> in fixtures that use the actions harness","Open the datepicker before querying its actions","Keep template buttons inside the mat-datepicker-actions container so locators find them","Assert fixture template content early in the test with a clear failure message"],"tags":["angular","testing","component-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"}