vitest-dev/vitest · error · Error
Method "getByLabelText" is not supported by the
Error message
Method "getByLabelText" is not supported by the "${provider}" provider. What it means
page.getByLabelText is a locator method only provided by full browser-automation providers. The default page object throws this error, interpolating the active provider name, when the method is called without a provider that registers it. Identical in cause to the other locator stubs in the same object.
Solutions
- Configure test.browser.provider to 'playwright' or 'webdriverio' and install the provider package.
- Replace with a CSS/attribute query: document.querySelector('[aria-label="X"]') or label-for lookup.
- Register the method yourself via page.extend({ getByLabelText }) if building a custom provider.
Example fix
// before
const field = page.getByLabelText('Email')
// after (preview provider)
const field = document.querySelector('input[aria-label="Email"]')! Defensive patterns
Strategy: validation
Validate before calling
if (getBrowserState().provider === 'preview') {
document.querySelector('[aria-label="Email"]')
} else {
page.getByLabelText('Email')
} Type guard
function supportsLocators(): boolean {
return ['playwright', 'webdriverio'].includes(getBrowserState().provider ?? '')
} Prevention
- Use a full provider when locator APIs are required.
- Map label-based queries to attribute selectors under preview.
- Centralize provider-capability checks in a test helper.
When it happens
Trigger: Calling page.getByLabelText(...) under the preview provider or any custom provider that has not registered a getByLabelText implementation via page.extend().
Common situations: Form-testing code copied from Playwright docs into a preview-provider Vitest project; missing provider installation; wrong provider string in config.
Related errors
- Method "elementLocator" is not supported by the
- Method "frameLocator" is not supported by the
- Method "getByAltText" is not supported by the
- Method "getByPlaceholder" is not supported by the
- Method "getByRole" is not supported by the
AI-assisted analysis of vitest-dev/vitest@1fa9837ec2 (2026-08-11).
Data as JSON: /api/errors/c359b485f110b8b8.
Report an issue: GitHub.
Appendix: source
Thrown at packages/browser/src/client/tester/context.ts:443
}
if (!hasActiveTrace) {
return Promise.resolve()
}
return triggerCommand(
'__vitest_markTrace',
[{
name,
stack: bodyOrOptions?.stack ?? error?.stack,
}],
error,
)
})
},
getByRole() {
throw new Error(`Method "getByRole" is not supported by the "${provider}" provider.`)
},
getByLabelText() {
throw new Error(`Method "getByLabelText" is not supported by the "${provider}" provider.`)
},
getByTestId() {
throw new Error(`Method "getByTestId" is not supported by the "${provider}" provider.`)
},
getByAltText() {
throw new Error(`Method "getByAltText" is not supported by the "${provider}" provider.`)
},
getByPlaceholder() {
throw new Error(`Method "getByPlaceholder" is not supported by the "${provider}" provider.`)
},
getByText() {
throw new Error(`Method "getByText" is not supported by the "${provider}" provider.`)
},
getByTitle() {
throw new Error(`Method "getByTitle" is not supported by the "${provider}" provider.`)
},
elementLocator() {
throw new Error(`Method "elementLocator" is not supported by the "${provider}" provider.`)View on GitHub (pinned to 1fa9837ec2)