Skip to content

Commit 94cd4dc

Browse files
test(wdio-browserstack-service): guard a11y Browser type augmentation
Add a type-level test asserting the 5 accessibility methods (startA11yScanning, stopA11yScanning, performScan, getAccessibilityResults, getAccessibilityResultsSummary) are typed on WebdriverIO.Browser. These declarations previously lived in an un-emitted ambient file and silently never reached consumers; this test fails if the published augmentation ever regresses again. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent ee6aaa1 commit 94cd4dc

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { expectType } from 'tsd'
2+
import { browser } from '@wdio/globals'
3+
4+
/**
5+
* Regression guard for the @wdio/browserstack-service accessibility
6+
* augmentation of WebdriverIO.Browser.
7+
*
8+
* These five methods are declared inside
9+
* declare global { namespace WebdriverIO { interface Browser { ... } } }
10+
* in packages/wdio-browserstack-service/src/index.ts. They previously lived
11+
* in an un-emitted ambient .d.ts file and silently never reached the published
12+
* build/index.d.ts, so consumers lost the typings. This file pulls in the
13+
* published @wdio/browserstack-service types (it is listed in this suite's
14+
* tsconfig.json `types` array) and fails `test:typings:webdriverio` if any of
15+
* the five methods ever stops being typed on WebdriverIO.Browser again.
16+
*/
17+
;(async () => {
18+
expectType<() => Promise<Record<string, unknown>>>(browser.getAccessibilityResultsSummary)
19+
expectType<() => Promise<Array<Record<string, unknown>>>>(browser.getAccessibilityResults)
20+
expectType<() => Promise<Record<string, unknown> | undefined>>(browser.performScan)
21+
expectType<() => Promise<void>>(browser.startA11yScanning)
22+
expectType<() => Promise<void>>(browser.stopA11yScanning)
23+
24+
// also assert the call-site return types resolve as declared
25+
expectType<Record<string, unknown>>(await browser.getAccessibilityResultsSummary())
26+
expectType<Array<Record<string, unknown>>>(await browser.getAccessibilityResults())
27+
expectType<Record<string, unknown> | undefined>(await browser.performScan())
28+
expectType<void>(await browser.startA11yScanning())
29+
expectType<void>(await browser.stopA11yScanning())
30+
})

0 commit comments

Comments
 (0)