{"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/d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09/packages/browser/src/client/tester/context.ts#L428-L464","documentation":"page.getByTestId is a throwing stub (packages/browser/src/client/tester/context.ts:445-446). Test-id queries at the page level aren't implemented by default; the Locator class implements getByTestId (locators.ts:265) using server.config.browser.locators.testIdAttribute. Calling the page-level stub throws.","triggerScenarios":"Calling page.getByTestId('submit') on the page object directly, with no registered extension.","commonSituations":"Assuming Vitest's page mirrors Playwright's page.getByTestId; importing page and calling getByTestId before setting up locators.","solutions":["Use a Locator: page.elementLocator(document.body).getByTestId('submit').","If you renamed the test id attribute (data-testid -> data-test), configure browser.locators.testIdAttribute and still query through a Locator.","Register page.getByTestId via browser.locators.extend(...) if a top-level shortcut is required."],"exampleFix":"// before\nconst el = page.getByTestId('submit')\n// after\nconst el = page.elementLocator(document.body).getByTestId('submit')","handlingStrategy":"type-guard","validationCode":"const root = page.elementLocator(document.body)\nconst el = root.getByTestId('submit')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use page.elementLocator(...).getByTestId rather than page.getByTestId.","Confirm browser.locators.testIdAttribute matches the attribute your components render."],"tags":["browser","locators","getbytestid","page","unsupported"],"analyzedSha":"d568f8ce3739b532d5bf2c1ee1e45e8a8a473d09","analyzedAt":"2026-08-03T20:23:56.861Z","schemaVersion":2}