{"record":{"id":"51ce5a41e51a6187","repo":"angular/components","slug":"getstartthumb-is-only-applicable-for-range-slide","errorCode":null,"errorMessage":"`getStartThumb` is only applicable for range sliders. Did you mean to use `getEndThumb`?","messagePattern":"`getStartThumb` is only applicable for range sliders\\. Did you mean to use `getEndThumb`\\?","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/material/slider/testing/slider-harness.ts","lineNumber":43,"sourceCode":"   * @return a `HarnessPredicate` configured with the given options.\n   */\n  static with<T extends MatSliderHarness>(\n    this: ComponentHarnessConstructor<T>,\n    options: SliderHarnessFilters = {},\n  ): HarnessPredicate<T> {\n    return new HarnessPredicate(this, options)\n      .addOption('isRange', options.isRange, async (harness, value) => {\n        return (await harness.isRange()) === value;\n      })\n      .addOption('disabled', options.disabled, async (harness, disabled) => {\n        return (await harness.isDisabled()) === disabled;\n      });\n  }\n\n  /** Gets the start thumb of the slider (only applicable for range sliders). */\n  async getStartThumb(): Promise<MatSliderThumbHarness> {\n    if (!(await this.isRange())) {\n      throw Error(\n        '`getStartThumb` is only applicable for range sliders. ' +\n          'Did you mean to use `getEndThumb`?',\n      );\n    }\n    return this.locatorFor(MatSliderThumbHarness.with({position: ThumbPosition.START}))();\n  }\n\n  /** Gets the thumb (for single point sliders), or the end thumb (for range sliders). */\n  async getEndThumb(): Promise<MatSliderThumbHarness> {\n    return this.locatorFor(MatSliderThumbHarness.with({position: ThumbPosition.END}))();\n  }\n\n  /** Gets whether the slider is a range slider. */\n  async isRange(): Promise<boolean> {\n    return await (await this.host()).hasClass('mdc-slider--range');\n  }\n\n  /** Gets whether the slider is disabled. */","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/angular/components/blob/0411926e7d8ae06b32236ec1048a888cfad5abf2/src/material/slider/testing/slider-harness.ts#L25-L61","documentation":"The slider test harness's `getStartThumb` only applies to range sliders; calling it on a single-value slider throws this error and suggests `getEndThumb`. Start/end thumbs exist only when the slider has start+end inputs; a plain slider exposes just one thumb.","triggerScenarios":"`await harness.getStartThumb()` on a `MatSliderHarness` whose DOM contains a single `matSliderThumb` input (not a range).","commonSituations":"Reusing a test written for a range slider against a single-value slider; switching a component template from range to single thumb without updating tests; assuming start thumb always exists.","solutions":["Use `await harness.getEndThumb()` (or `getThumb()`) to get the single thumb of a non-range slider.","Guard with `if (await harness.isRange())` before calling `getStartThumb`.","Update the fixture template to a range slider (start+end inputs) if a start thumb is genuinely needed."],"exampleFix":"// before\nconst thumb = await sliderHarness.getStartThumb();\n// after\nconst thumb = (await sliderHarness.isRange())\n  ? await sliderHarness.getStartThumb()\n  : await sliderHarness.getEndThumb();","handlingStrategy":"type-guard","validationCode":"const isRange = await sliderHarness.isRange();\nif (!isRange) {\n  const thumb = await sliderHarness.getEndThumb();\n} else {\n  const start = await sliderHarness.getStartThumb();\n}","typeGuard":"async function hasStartThumb(h: MatSliderHarness): Promise<boolean> {\n  return h.isRange();\n}","tryCatchPattern":"try {\n  const thumb = await sliderHarness.getStartThumb();\n} catch (e) {\n  if ((e as Error).message.includes('only applicable for range sliders')) {\n    return sliderHarness.getEndThumb();\n  }\n  throw e;\n}","preventionTips":["Check `isRange()` before using start/end thumb APIs.","Keep harness tests in sync when switching a slider between single and range modes."],"tags":["angular","material","testing","test-harness"],"backgroundTag":"harness-api-misuse","analyzedSha":"0411926e7d8ae06b32236ec1048a888cfad5abf2","analyzedAt":"2026-08-31T11:58:23.400Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}