|
| 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