Skip to content

Commit 83f39a5

Browse files
committed
fix(webdriverio): correcly use @testplane/devtools
1 parent ac5d5e9 commit 83f39a5

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

packages/webdriverio/src/constants.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,28 @@ export const WDIO_DEFAULTS: Options.Definition<Capabilities.WebdriverIOConfig> =
4242
return
4343
}
4444

45+
const packageName = param === SupportedAutomationProtocols.stub ? param : `@testplane/${param}`
46+
4547
try {
46-
import.meta.resolve(param)
48+
import.meta.resolve(packageName)
4749
} catch (err) {
4850
const error = err instanceof Error ? err : new Error('unknown error')
49-
throw new Error(`Couldn't find automation protocol "${param}": ${error.message}`)
51+
throw new Error(`Couldn't find automation protocol "${packageName}": ${error.message}`)
5052
}
5153

5254
try {
5355
const __dirname = dirname(fileURLToPath(import.meta.url))
5456
const require = createRequire(import.meta.url)
55-
const id = param === SupportedAutomationProtocols.stub
56-
? resolve(__dirname, '..', 'build', param)
57-
: param
57+
const id = packageName === SupportedAutomationProtocols.stub
58+
? resolve(__dirname, '..', 'build', packageName)
59+
: packageName
5860
require.resolve(id)
5961
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
6062
} catch (err: any) {
6163
/* istanbul ignore next */
6264
throw new Error(
6365
'Automation protocol package is not installed!\n' +
64-
`Please install it via \`npm install ${param}\``
66+
`Please install it via \`npm install ${packageName}\``
6567
)
6668
}
6769
}

packages/webdriverio/src/utils/driver.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ export async function getProtocolDriver (options: Capabilities.WebdriverIOConfig
4646
*/
4747
if (automationProtocol === SupportedAutomationProtocols.devtools || automationProtocol?.startsWith('/@fs/')) {
4848
try {
49-
const DevTools = await import(`@testplane/${automationProtocol}`)
49+
const packageName = automationProtocol === 'devtools' ? `@testplane/${automationProtocol}` : automationProtocol
50+
const DevTools = await import(packageName)
5051
log.info('Starting session using Chrome DevTools as automation protocol and Puppeteer as driver')
5152
return { Driver: DevTools.default, options }
5253
} catch (err: unknown) {

0 commit comments

Comments
 (0)