MCPcopy Create free account
hub / github.com/webdriverio/webdriverio / transformCommandScript

Function transformCommandScript

packages/wdio-reporter/src/utils.ts:116–136  ·  view source on GitHub ↗
(script?: string|Function)

Source from the content-addressed store, hash-verified

114 * @param script WebDriver command script
115 */
116export function transformCommandScript (script?: string|Function) {
117 if (!script) {
118 return script
119 }
120 let name = undefined
121 if (typeof script === 'string') {
122 name = FIRST_FUNCTION_REGEX.exec(script)
123 // reset the static RegExp globals to avoid leaking `script`
124 FIRST_FUNCTION_REGEX.exec('')
125 } else if (typeof script === 'function') {
126 name = script.name
127 script = script.toString()
128 } else {
129 return `<${typeof script}>`
130 }
131
132 if (typeof name === 'string' && name) {
133 return `<script fn ${name}(...)> [${Buffer.byteLength(script, 'utf-8')} bytes]`
134 }
135 return `<script> [${Buffer.byteLength(script, 'utf-8')} bytes]`
136}

Callers 1

constructorMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…