{"record":{"id":"96846922697faf37","repo":"vitest-dev/vitest","slug":"method-getbytestid-is-not-supported-by-the-pr","errorCode":null,"errorMessage":"Method \"getByTestId\" is not supported by the \"${provider}\" provider.","messagePattern":"Method \"getByTestId\" is not supported by the \"(.+?)\" provider\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/browser/src/client/tester/context.ts","lineNumber":446,"sourceCode":"      }\n      return triggerCommand(\n        '__vitest_markTrace',\n        [{\n          name,\n          stack: bodyOrOptions?.stack ?? error?.stack,\n        }],\n        error,\n      )\n    })\n  },\n  getByRole() {\n    throw new Error(`Method \"getByRole\" is not supported by the \"${provider}\" provider.`)\n  },\n  getByLabelText() {\n    throw new Error(`Method \"getByLabelText\" is not supported by the \"${provider}\" provider.`)\n  },\n  getByTestId() {\n    throw new Error(`Method \"getByTestId\" is not supported by the \"${provider}\" provider.`)\n  },\n  getByAltText() {\n    throw new Error(`Method \"getByAltText\" is not supported by the \"${provider}\" provider.`)\n  },\n  getByPlaceholder() {\n    throw new Error(`Method \"getByPlaceholder\" is not supported by the \"${provider}\" provider.`)\n  },\n  getByText() {\n    throw new Error(`Method \"getByText\" is not supported by the \"${provider}\" provider.`)\n  },\n  getByTitle() {\n    throw new Error(`Method \"getByTitle\" is not supported by the \"${provider}\" provider.`)\n  },\n  elementLocator() {\n    throw new Error(`Method \"elementLocator\" is not supported by the \"${provider}\" provider.`)\n  },\n  frameLocator() {\n    throw new Error(`Method \"frameLocator\" is not supported by the \"${provider}\" provider.`)","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/vitest-dev/vitest/blob/1fa9837ec26533512fdcad8baebf249771bd340a/packages/browser/src/client/tester/context.ts#L428-L464","documentation":"page.getByTestId is a locator method that requires a full provider. The default page stub throws, naming the active provider, when getByTestId is invoked without a registered implementation. Test IDs are provider-specific selectors (Playwright uses testid engines), so preview cannot satisfy the call.","triggerScenarios":"Calling page.getByTestId('submit') under the preview provider; using the data-testid convention while provider is preview; calling before the provider plugin registered the method.","commonSituations":"Component tests migrated from @testing-library that rely on getByTestId; default provider config; missing provider install.","solutions":["Switch provider to 'playwright' or 'webdriverio' and install the matching package.","Under preview, query directly: document.querySelector('[data-testid=\"submit\"]').","Set test.browser.locators.testIdAttribute if your test IDs use a custom attribute."],"exampleFix":"// before\nconst el = page.getByTestId('submit')\n// after (preview provider)\nconst el = document.querySelector('[data-testid=\"submit\"]')!","handlingStrategy":"validation","validationCode":"if (getBrowserState().provider === 'preview') {\n  document.querySelector('[data-testid=\"submit\"]')\n} else {\n  page.getByTestId('submit')\n}","typeGuard":"function supportsLocators(): boolean {\n  return ['playwright', 'webdriverio'].includes(getBrowserState().provider ?? '')\n}","tryCatchPattern":null,"preventionTips":["Pin a full provider when tests use getByTestId.","Set test.browser.locators.testIdAttribute if using a custom data-* attribute.","Fall back to [data-testid=\"...\"] queries under preview."],"tags":["browser","locators","provider","preview","testid"],"backgroundTag":null,"analyzedSha":"1fa9837ec26533512fdcad8baebf249771bd340a","analyzedAt":"2026-08-11T16:11:39.638Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}