Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference path="./@types/bstack-service-types.d.ts" />
import util from 'node:util'

import type { Capabilities, Frameworks, Options } from '@wdio/types'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference path="../../@types/bstack-service-types.d.ts" />
import BaseModule from './baseModule.js'
import { BrowserstackCLI } from '../index.js'
import { BStackLogger } from '../cliLogger.js'
Expand Down
8 changes: 8 additions & 0 deletions packages/wdio-browserstack-service/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ export * from './types.js'
declare global {
namespace WebdriverIO {
interface ServiceOption extends BrowserstackConfig {}

interface Browser {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No regression guard ships with this. These declarations lived in an un-emitted ambient file since the original v8 a11y PR and silently never reached consumers across multiple subsequent PRs — exactly the kind of failure that recurs. Recommend adding a type-level test (tsd, or a tests/typings fixture compiled in CI) that asserts browser.startA11yScanning, getAccessibilityResultsSummary, etc. are typed on WebdriverIO.Browser. That way CI fails if the augmentation ever stops emitting again, instead of a customer finding it.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 94cd4dc49tests/typings/webdriverio/browserstackService.ts asserts (tsd expectType) that all 5 a11y methods are typed on WebdriverIO.Browser, both as function properties and via their awaited return types.

It hooks into the repo's existing test:typings:webdriverio CI script — that suite already symlinks the package's built types and lists @wdio/browserstack-service in its tsconfig types, so the guard checks the exact published consumer surface that regressed here. No new framework or CI job added.

Verified: compiles clean with the augmentation present, and fails with TS2339 on all 5 methods if the interface Browser block is removed.

getAccessibilityResultsSummary: () => Promise<Record<string, unknown>>,
getAccessibilityResults: () => Promise<Array<Record<string, unknown>>>,
performScan: () => Promise<Record<string, unknown> | undefined>,
startA11yScanning: () => Promise<void>,
stopA11yScanning: () => Promise<void>
}
}
interface State {
value: number,
Expand Down
30 changes: 30 additions & 0 deletions tests/typings/webdriverio/browserstackService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { expectType } from 'tsd'
import { browser } from '@wdio/globals'

/**
* Regression guard for the @wdio/browserstack-service accessibility
* augmentation of WebdriverIO.Browser.
*
* These five methods are declared inside
* declare global { namespace WebdriverIO { interface Browser { ... } } }
* in packages/wdio-browserstack-service/src/index.ts. They previously lived
* in an un-emitted ambient .d.ts file and silently never reached the published
* build/index.d.ts, so consumers lost the typings. This file pulls in the
* published @wdio/browserstack-service types (it is listed in this suite's
* tsconfig.json `types` array) and fails `test:typings:webdriverio` if any of
* the five methods ever stops being typed on WebdriverIO.Browser again.
*/
;(async () => {
expectType<() => Promise<Record<string, unknown>>>(browser.getAccessibilityResultsSummary)
expectType<() => Promise<Array<Record<string, unknown>>>>(browser.getAccessibilityResults)
expectType<() => Promise<Record<string, unknown> | undefined>>(browser.performScan)
expectType<() => Promise<void>>(browser.startA11yScanning)
expectType<() => Promise<void>>(browser.stopA11yScanning)

// also assert the call-site return types resolve as declared
expectType<Record<string, unknown>>(await browser.getAccessibilityResultsSummary())
expectType<Array<Record<string, unknown>>>(await browser.getAccessibilityResults())
expectType<Record<string, unknown> | undefined>(await browser.performScan())
expectType<void>(await browser.startA11yScanning())
expectType<void>(await browser.stopA11yScanning())
})
Loading