webdriverio/packages/webdriver/src/environment.ts
Christian Bromann 6464dc7d4a
fix(@wdio/jasmine-framework): become independant from expect-webdriverio (#14592)
* fix(@wdio/jasmine-framework): become independant from expect-webdriverio

* remove console.log

* get tests to work

* fix(ci): add eslint as dep

* fix tests

* run unit tests on Node.js 20, 22 and 24

* move @sveltejs/vite-plugin-svelte to browser runner

* remove usage of Node.js primitives in webdriver and webdriverio

* fix unit tests

* skip svelte test for now

* increase timeouts

* fix component test

* increase timeouts

* increase timeouts

* increase timeouts

* fix imageSize call
2025-07-08 12:51:42 -07:00

50 lines
1.6 KiB
TypeScript

import type WebSocket from 'ws'
import type { Options } from '@wdio/types'
import type { BrowserSocket } from './bidi/socket.js'
import type { FetchRequest } from './request/web.js'
/**
* @internal
*/
export const isNode = !!(typeof process !== 'undefined' && process.version)
export interface EnvironmentVariables {
WEBDRIVER_CACHE_DIR?: string
WDIO_LOG_LEVEL?: Options.WebDriverLogTypes
PROXY_URL?: string
NO_PROXY?: string[]
DISABLE_WEBDRIVERIO_DEPRECATION_WARNINGS?: string
WDIO_WORKER_ID?: string
WDIO_UNIT_TESTS?: string
}
export interface EnvironmentDependencies {
Request: typeof FetchRequest,
Socket: typeof BrowserSocket,
createBidiConnection: (wsUrl?: string, options?: WebSocket.ClientOptions) => Promise<WebSocket | undefined>,
variables: EnvironmentVariables
}
/**
* Holder for environment dependencies. These dependencies cannot
* be used during the module instantiation.
*/
export const environment: {
value: EnvironmentDependencies;
} = {
value: {
get Request(): EnvironmentDependencies['Request'] {
throw new Error('Request is not available in this environment')
},
get Socket(): EnvironmentDependencies['Socket'] {
throw new Error('Socket is not available in this environment')
},
get createBidiConnection(): EnvironmentDependencies['createBidiConnection'] {
throw new Error('createBidiConnection is not available in this environment')
},
get variables(): EnvironmentDependencies['variables'] {
return {} as EnvironmentVariables
}
}
}