@flakemetry/wdio-reporter 0.0.0-stage → 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +95 -2
- package/dist/index.cjs +640 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +157 -0
- package/dist/index.d.ts +158 -0
- package/dist/index.js +611 -0
- package/dist/index.js.map +1 -0
- package/package.json +73 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/mapping.ts","../src/collector.ts","../src/capabilities.ts","../src/reporter.ts"],"sourcesContent":["import { basename, dirname, extname, isAbsolute, join, relative, sep } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { stripVTControlCharacters } from 'node:util'\n\nimport type { SpanStatus } from '@flakemetry/contracts'\nimport type { RecordedTest, ShardInfo } from '@flakemetry/sdk'\n\nexport interface WdioError {\n name?: string\n type?: string\n message?: string\n stack?: string\n}\n\nexport type Capabilities = Record<string, unknown>\n\nconst STACK_FRAME = /^\\s+at\\s/\nconst MAX_MESSAGE_LENGTH = 8000\nconst MAX_VARIANT_LENGTH = 100\nconst MAX_IDEMPOTENCY_KEY_LENGTH = 128\n\nconst NOT_RUN = [\n /^Test skipped due to failure in hook\\b/,\n /^Not run because a beforeAll function failed\\b/,\n]\n\nexport const stripAnsi = (value: string): string => stripVTControlCharacters(value)\n\nexport const errorOf = (\n errors: readonly WdioError[] | undefined,\n error: WdioError | undefined,\n): WdioError | undefined => errors?.find((candidate) => Boolean(candidate)) ?? error ?? undefined\n\nexport const neverRan = (error: WdioError | undefined): boolean => {\n const message = stripAnsi(error?.message ?? '').trim()\n return NOT_RUN.some((pattern) => pattern.test(message))\n}\n\nexport const summarizeError = (\n error: WdioError | undefined,\n fallback: string,\n): { type: string | null; message: string; stack: string | null } => {\n const lines = stripAnsi(error?.message ?? '').split('\\n')\n const frame = lines.findIndex((line) => STACK_FRAME.test(line))\n const message = (frame === -1 ? lines : lines.slice(0, frame)).join('\\n').trim()\n return {\n type: error?.name ?? error?.type ?? null,\n message: message.length > 0 ? message.slice(0, MAX_MESSAGE_LENGTH) : fallback,\n stack: error?.stack ? stripAnsi(error.stack) : null,\n }\n}\n\nexport const commandStatus = (\n result: unknown,\n): { status: SpanStatus; error: { type: string | null; message: string } | null } => {\n const record = result && typeof result === 'object' ? (result as Record<string, unknown>) : {}\n const thrown = record.error\n if (thrown) {\n const detail = thrown as WdioError\n return {\n status: 'error',\n error: {\n type: detail.name ?? null,\n message: stripAnsi(detail.message ?? String(thrown)).split('\\n')[0] || 'command failed',\n },\n }\n }\n const value = record.value as { error?: unknown; message?: unknown } | null | undefined\n if (value && typeof value === 'object' && typeof value.error === 'string') {\n const detail = {\n error: value.error,\n message: typeof value.message === 'string' ? value.message : undefined,\n }\n return {\n status: 'error',\n error: {\n type: detail.error,\n message: stripAnsi(detail.message ?? detail.error).split('\\n')[0] || detail.error,\n },\n }\n }\n return { status: 'ok', error: null }\n}\n\nexport const toFilePath = (raw: string | undefined): string | undefined => {\n if (!raw || raw === 'unknown spec file') return undefined\n if (raw.startsWith('file://')) {\n try {\n return fileURLToPath(raw)\n } catch {\n return undefined\n }\n }\n return raw\n}\n\nexport const relativize = (rootDir: string, filePath: string): string => {\n if (!isAbsolute(filePath)) return filePath.split(sep).join('/')\n const inside = relative(rootDir, filePath)\n const chosen = inside && !inside.startsWith('..') && !isAbsolute(inside) ? inside : filePath\n return chosen.split(sep).join('/')\n}\n\nconst text = (value: unknown): string | undefined =>\n typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined\n\nconst unwrap = (capabilities: Capabilities): Capabilities => {\n const alwaysMatch = capabilities.alwaysMatch\n return alwaysMatch && typeof alwaysMatch === 'object'\n ? { ...(alwaysMatch as Capabilities), ...capabilities }\n : capabilities\n}\n\nexport const explicitVariant = (capabilities: Capabilities | undefined): string | undefined =>\n capabilities ? text(unwrap(capabilities)['flakemetry:variant']) : undefined\n\nexport const capabilityLabel = (capabilities: Capabilities | undefined): string | undefined => {\n if (!capabilities) return undefined\n const caps = unwrap(capabilities)\n const explicit = text(caps['flakemetry:variant'])\n if (explicit) return explicit\n const platform = text(caps.platformName)\n const target = text(caps.browserName) ?? text(caps['appium:deviceName']) ?? text(caps.deviceName)\n const label = [platform, target].filter(Boolean).join(' ')\n return label.length > 0 ? label : undefined\n}\n\nexport const capabilityIndex = (cid: string | undefined): number | undefined => {\n const index = Number.parseInt(cid ?? '', 10)\n return Number.isInteger(index) && index >= 0 ? index : undefined\n}\n\nexport interface VariantInput {\n cid?: string\n requested?: Capabilities\n configured?: readonly Capabilities[] | null\n multiremote?: boolean\n}\n\nexport const resolveVariant = ({\n cid,\n requested,\n configured,\n multiremote,\n}: VariantInput): string | undefined => {\n if (multiremote) return undefined\n const index = capabilityIndex(cid)\n const own = index !== undefined ? configured?.[index] : undefined\n const explicit = explicitVariant(requested) ?? explicitVariant(own)\n if (explicit) return explicit.slice(0, MAX_VARIANT_LENGTH)\n if (!configured || configured.length < 2 || index === undefined) return undefined\n\n const labels = configured.map(\n (capabilities, position) => capabilityLabel(capabilities) ?? `capability ${position + 1}`,\n )\n const label = labels[index] ?? capabilityLabel(requested) ?? `capability ${index + 1}`\n const shared = labels.filter((candidate) => candidate === label).length > 1\n return (shared ? `${label} (${index + 1})` : label).slice(0, MAX_VARIANT_LENGTH)\n}\n\nexport const shardOf = (shard: unknown): ShardInfo | null => {\n if (!shard || typeof shard !== 'object') return null\n const { current, total } = shard as { current?: unknown; total?: unknown }\n return typeof current === 'number' && typeof total === 'number' && total > 1\n ? { current, total }\n : null\n}\n\nexport const workerOutputFile = (file: string, cid: string): string => {\n const extension = extname(file)\n const name = basename(file, extension)\n const worker = cid.replace(/[^\\w.-]+/g, '-')\n return join(dirname(file), `${name}-${worker}${extension}`)\n}\n\nexport const workerIdempotencyKey = (key: string, cid: string): string => {\n const suffix = `-w${cid.replace(/[^\\w.-]+/g, '-')}`\n return `${key.slice(0, MAX_IDEMPOTENCY_KEY_LENGTH - suffix.length)}${suffix}`\n}\n\nexport const runFailed = (tests: readonly RecordedTest[]): boolean =>\n tests.some((test) => test.status === 'fail')\n","import { sep } from 'node:path'\n\nimport { type JsonRecord, MAX_SPANS_PER_EXECUTION, type TestStatus } from '@flakemetry/contracts'\nimport type { RecordedStep, RecordedTest } from '@flakemetry/sdk'\n\nimport {\n commandStatus,\n errorOf,\n neverRan,\n relativize,\n summarizeError,\n toFilePath,\n type WdioError,\n} from './mapping'\n\nexport interface WdioSuite {\n uid: string\n title: string\n file?: string\n parentUid?: string | null\n}\n\nexport interface WdioTest {\n uid: string\n title: string\n start?: Date | number\n duration?: number\n error?: WdioError\n errors?: WdioError[]\n file?: string\n parentUid?: string | null\n contextId?: string\n}\n\nexport interface WdioHook {\n uid: string\n title: string\n start?: Date | number\n duration?: number\n state?: string\n error?: WdioError\n errors?: WdioError[]\n file?: string\n parentUid?: string | null\n hookSuiteUid?: string\n contextId?: string\n retried?: boolean\n failedTestUid?: string\n}\n\nexport interface WdioCommand {\n command?: string\n method?: string\n endpoint?: string\n result?: unknown\n contextId?: string\n}\n\nexport interface WdioAssertion {\n matcherName?: string\n result?: unknown\n contextId?: string\n}\n\nexport interface FinishOptions {\n rootDir: string\n variant?: string\n}\n\ninterface OpenCommand {\n key: string\n step: RecordedStep\n started: number\n}\n\ninterface Owner {\n uid: string\n contextId?: string\n title: string\n suite: string[]\n suiteUids: string[]\n file: string | undefined\n startedAt: Date\n steps: RecordedStep[]\n spans: number\n commands: OpenCommand[]\n assertions: { step: RecordedStep; started: number }[]\n}\n\ninterface Attempt extends Owner {\n type: 'test'\n key: string\n attempt: number\n retryOf: number | null\n outcome?: 'pass' | 'fail' | 'skip'\n error?: WdioError\n stats: WdioTest\n}\n\ninterface Hook extends Owner {\n type: 'hook'\n stats: WdioHook\n}\n\ninterface Collected {\n file: string | undefined\n test: Omit<RecordedTest, 'filePath'>\n}\n\nconst SUITE_SEPARATOR = ' > '\nconst NODE_MODULES = `${sep}node_modules${sep}`\n\nconst usableFile = (raw: string | undefined): string | undefined => {\n const file = toFilePath(raw)\n return file && !file.includes(NODE_MODULES) && !file.includes('/node_modules/') ? file : undefined\n}\n\nexport class WdioCollector {\n private readonly suites = new Map<string, WdioSuite>()\n private readonly stack: string[] = []\n private readonly owners: (Attempt | Hook)[] = []\n private readonly retrying = new Map<string, { attempt: number; firstIndex: number }>()\n private readonly collected: Collected[] = []\n private fallbackFile: string | undefined\n\n constructor(private readonly now: () => number = Date.now) {}\n\n get size(): number {\n return this.collected.length\n }\n\n setSpecs(specs: readonly string[] | undefined): void {\n this.fallbackFile = usableFile(specs?.[0])\n }\n\n suiteStart(suite: WdioSuite): void {\n this.suites.set(suite.uid, suite)\n this.stack.push(suite.uid)\n }\n\n suiteEnd(suite: WdioSuite): void {\n for (const owner of [...this.owners]) {\n if (owner.type === 'test' && owner.suiteUids.includes(suite.uid)) this.finalize(owner)\n }\n const index = this.stack.lastIndexOf(suite.uid)\n if (index !== -1) this.stack.splice(index, 1)\n }\n\n hookStart(hook: WdioHook): void {\n this.owners.push({ type: 'hook', stats: hook, ...this.ownerBase(hook, hook.start) })\n }\n\n hookEnd(hook: WdioHook): void {\n const owner = this.findOwner('hook', hook.uid)\n if (!owner) return\n this.remove(owner)\n this.closeOpen(owner)\n const durationMs = this.durationOf(hook.duration, owner.startedAt)\n const error = errorOf(hook.errors, hook.error)\n const failed = Boolean(error) || hook.state === 'failed'\n\n if (failed) {\n if (hook.retried || hook.failedTestUid) return\n this.collected.push({\n file: owner.file,\n test: {\n suite: owner.suite.join(SUITE_SEPARATOR),\n title: owner.title || 'hook',\n status: 'fail',\n attempt: 1,\n retryOfIndex: null,\n startedAt: owner.startedAt,\n durationMs,\n error: summarizeError(error, 'hook failed'),\n steps: owner.steps.length > 0 ? owner.steps : null,\n },\n })\n return\n }\n\n const attempt = this.latestOwner(hook.contextId, 'test')\n if (!attempt) return\n this.addStep(attempt, attempt.steps, {\n name: owner.title || 'hook',\n kind: 'step',\n startedAt: owner.startedAt,\n durationMs,\n status: 'ok',\n ...(owner.steps.length > 0 ? { children: owner.steps } : {}),\n })\n attempt.spans += owner.spans\n }\n\n testStart(test: WdioTest): void {\n if (this.findOwner('test', test.uid)) return\n this.open(test)\n }\n\n testPass(test: WdioTest): void {\n this.attemptFor(test).outcome = 'pass'\n }\n\n testFail(test: WdioTest): void {\n const attempt = this.attemptFor(test)\n const error = errorOf(test.errors, test.error)\n attempt.outcome = neverRan(error) ? 'skip' : 'fail'\n attempt.error = attempt.outcome === 'fail' ? error : undefined\n }\n\n testRetry(test: WdioTest): void {\n const attempt = this.attemptFor(test)\n attempt.outcome = 'fail'\n attempt.error = errorOf(test.errors, test.error)\n const index = this.finalize(attempt)\n this.retrying.set(attempt.key, {\n attempt: attempt.attempt,\n firstIndex: attempt.retryOf ?? index,\n })\n }\n\n testSkip(test: WdioTest): void {\n this.attemptFor(test).outcome = 'skip'\n }\n\n testEnd(test: WdioTest): void {\n const attempt = this.findOwner('test', test.uid)\n if (attempt) this.finalize(attempt)\n }\n\n beforeCommand(command: WdioCommand): void {\n const owner = this.latestOwner(command.contextId)\n if (!owner) return\n const parent = owner.assertions.at(-1)?.step\n const started = this.now()\n const attributes: JsonRecord = {}\n if (command.command) attributes['wdio.command'] = command.command\n if (command.method) attributes['http.request.method'] = command.method\n if (command.endpoint) attributes['url.path'] = command.endpoint\n const step: RecordedStep = {\n name: command.command || 'command',\n kind: 'browser',\n startedAt: new Date(started),\n durationMs: 0,\n status: 'unset',\n attributes,\n }\n if (!this.addStep(owner, parent ? (parent.children ??= []) : owner.steps, step)) return\n owner.commands.push({ key: this.commandKey(command), step, started })\n }\n\n afterCommand(command: WdioCommand): void {\n const owner = this.latestOwner(command.contextId)\n if (!owner) return\n const key = this.commandKey(command)\n const index = owner.commands.findIndex((open) => open.key === key)\n if (index === -1) return\n const [open] = owner.commands.splice(index, 1)\n if (!open) return\n const outcome = commandStatus(command.result)\n open.step.durationMs = Math.max(0, this.now() - open.started)\n open.step.status = outcome.status\n open.step.error = outcome.error\n }\n\n beforeAssertion(assertion: WdioAssertion): void {\n const owner = this.latestOwner(assertion.contextId)\n if (!owner) return\n const parent = owner.assertions.at(-1)?.step\n const started = this.now()\n const step: RecordedStep = {\n name: `expect.${assertion.matcherName || 'assertion'}`,\n kind: 'step',\n startedAt: new Date(started),\n durationMs: 0,\n status: 'unset',\n }\n if (!this.addStep(owner, parent ? (parent.children ??= []) : owner.steps, step)) return\n owner.assertions.push({ step, started })\n }\n\n afterAssertion(assertion: WdioAssertion): void {\n const owner = this.latestOwner(assertion.contextId)\n const open = owner?.assertions.pop()\n if (!open) return\n open.step.durationMs = Math.max(0, this.now() - open.started)\n const pass = (assertion.result as { pass?: unknown } | undefined)?.pass\n if (typeof pass === 'boolean') open.step.attributes = { 'wdio.assertion.pass': pass }\n }\n\n finish({ rootDir, variant }: FinishOptions): RecordedTest[] {\n for (const owner of [...this.owners]) {\n if (owner.type === 'test') this.finalize(owner)\n else this.remove(owner)\n }\n return this.collected.map(({ file, test }) => ({\n ...test,\n filePath: file ? relativize(rootDir, file) : 'unknown',\n variant,\n }))\n }\n\n private ownerBase(stats: WdioTest | WdioHook, start: Date | number | undefined): Owner {\n const { titles, uids } = this.locate(stats)\n return {\n uid: stats.uid,\n contextId: stats.contextId,\n title: stats.title,\n suite: titles,\n suiteUids: uids,\n file: this.fileOf(stats.file, uids),\n startedAt: this.dateOf(start),\n steps: [],\n spans: 0,\n commands: [],\n assertions: [],\n }\n }\n\n private open(test: WdioTest): Attempt {\n const base = this.ownerBase(test, test.start)\n const key = [base.file ?? '', base.suite.join(SUITE_SEPARATOR), test.title].join('\\u0000')\n const stale = this.owners.find(\n (owner): owner is Attempt => owner.type === 'test' && owner.key === key,\n )\n if (stale) {\n this.remove(stale)\n this.closeOpen(stale)\n }\n const previous = stale ? undefined : this.retrying.get(key)\n if (previous) this.retrying.delete(key)\n const attempt: Attempt = {\n ...base,\n ...(stale ? { startedAt: stale.startedAt, steps: stale.steps, spans: stale.spans } : {}),\n type: 'test',\n stats: test,\n key,\n attempt: stale ? stale.attempt : previous ? previous.attempt + 1 : 1,\n retryOf: stale ? stale.retryOf : previous ? previous.firstIndex : null,\n }\n this.owners.push(attempt)\n return attempt\n }\n\n private attemptFor(test: WdioTest): Attempt {\n return this.findOwner('test', test.uid) ?? this.open(test)\n }\n\n private finalize(attempt: Attempt): number {\n this.remove(attempt)\n this.closeOpen(attempt)\n const status: TestStatus =\n attempt.outcome === 'pass'\n ? attempt.attempt > 1\n ? 'flaky'\n : 'pass'\n : attempt.outcome === 'fail'\n ? 'fail'\n : 'skip'\n this.collected.push({\n file: attempt.file,\n test: {\n suite: attempt.suite.join(SUITE_SEPARATOR),\n title: attempt.title || 'untitled',\n status,\n attempt: attempt.attempt,\n retryOfIndex: attempt.retryOf,\n startedAt: attempt.startedAt,\n durationMs: this.durationOf(attempt.stats.duration, attempt.startedAt),\n error: status === 'fail' ? summarizeError(attempt.error, 'test failed') : null,\n steps: attempt.steps.length > 0 ? attempt.steps : null,\n },\n })\n return this.collected.length - 1\n }\n\n private addStep(owner: Owner, siblings: RecordedStep[], step: RecordedStep): boolean {\n if (owner.spans >= MAX_SPANS_PER_EXECUTION) return false\n siblings.push(step)\n owner.spans += 1\n return true\n }\n\n private closeOpen(owner: Owner): void {\n const now = this.now()\n for (const open of owner.commands) open.step.durationMs = Math.max(0, now - open.started)\n for (const open of owner.assertions) open.step.durationMs = Math.max(0, now - open.started)\n owner.commands = []\n owner.assertions = []\n }\n\n private commandKey(command: WdioCommand): string {\n return `${command.command ?? ''} ${command.method ?? ''} ${command.endpoint ?? ''}`\n }\n\n private findOwner<T extends 'test' | 'hook'>(\n type: T,\n uid: string,\n ): (T extends 'test' ? Attempt : Hook) | undefined {\n for (let index = this.owners.length - 1; index >= 0; index -= 1) {\n const owner = this.owners[index]\n if (owner && owner.type === type && owner.uid === uid) {\n return owner as T extends 'test' ? Attempt : Hook\n }\n }\n return undefined\n }\n\n private latestOwner(contextId: string | undefined, type: 'test'): Attempt | undefined\n private latestOwner(contextId: string | undefined): Attempt | Hook | undefined\n private latestOwner(\n contextId: string | undefined,\n type?: 'test' | 'hook',\n ): Attempt | Hook | undefined {\n for (let index = this.owners.length - 1; index >= 0; index -= 1) {\n const owner = this.owners[index]\n if (!owner || (type && owner.type !== type)) continue\n if (contextId === undefined || owner.contextId === contextId) return owner\n }\n return undefined\n }\n\n private remove(owner: Attempt | Hook): void {\n const index = this.owners.indexOf(owner)\n if (index !== -1) this.owners.splice(index, 1)\n }\n\n private locate(stats: { parentUid?: string | null; hookSuiteUid?: string }): {\n titles: string[]\n uids: string[]\n } {\n const anchor = stats.hookSuiteUid ?? stats.parentUid\n const uids = anchor === null ? [] : ((anchor ? this.chain(anchor) : null) ?? [...this.stack])\n const titles = uids\n .map((uid) => this.suites.get(uid)?.title ?? '')\n .filter((title) => title.length > 0)\n return { titles, uids }\n }\n\n private chain(uid: string): string[] | null {\n const uids: string[] = []\n let current: string | null | undefined = uid\n while (current) {\n const suite = this.suites.get(current)\n if (!suite || suite.parentUid === undefined) return null\n uids.unshift(current)\n current = suite.parentUid\n }\n return uids\n }\n\n private fileOf(own: string | undefined, uids: readonly string[]): string | undefined {\n const direct = usableFile(own)\n if (direct) return direct\n for (let index = uids.length - 1; index >= 0; index -= 1) {\n const file = usableFile(this.suites.get(uids[index] ?? '')?.file)\n if (file) return file\n }\n return this.fallbackFile\n }\n\n private dateOf(start: Date | number | undefined): Date {\n if (start instanceof Date && !Number.isNaN(start.getTime())) return start\n if (typeof start === 'number' && Number.isFinite(start)) return new Date(start)\n return new Date(this.now())\n }\n\n private durationOf(duration: number | undefined, startedAt: Date): number {\n if (typeof duration === 'number' && Number.isFinite(duration)) {\n return Math.max(0, Math.round(duration))\n }\n return Math.max(0, Math.round(this.now() - startedAt.getTime()))\n }\n}\n","import { existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { pathToFileURL } from 'node:url'\n\nimport type { Capabilities } from './mapping'\n\nconst DEFAULT_CONFIG_FILES = [\n 'wdio.conf.ts',\n 'wdio.conf.js',\n 'wdio.conf.mts',\n 'wdio.conf.mjs',\n 'wdio.conf.cts',\n 'wdio.conf.cjs',\n]\nconst IMPLIED_EXTENSIONS = ['', '.ts', '.js']\n\nexport type ImportModule = (specifier: string) => Promise<unknown>\n\ninterface ConfigModule {\n config?: { capabilities?: unknown }\n default?: { config?: { capabilities?: unknown } }\n}\n\nconst isRecord = (value: unknown): value is Capabilities =>\n Boolean(value) && typeof value === 'object' && !Array.isArray(value)\n\nexport const findConfigFile = (\n config: Record<string, unknown> | undefined,\n cwd: string,\n exists: (path: string) => boolean = existsSync,\n): string | undefined => {\n const given = [config?.['config-path'], config?.configPath].find(\n (value): value is string => typeof value === 'string' && value.length > 0,\n )\n const candidates = given\n ? IMPLIED_EXTENSIONS.map((extension) => resolve(cwd, `${given}${extension}`))\n : DEFAULT_CONFIG_FILES.map((name) => resolve(cwd, name))\n return candidates.find((candidate) => exists(candidate))\n}\n\nexport const loadConfiguredCapabilities = async (\n config: Record<string, unknown> | undefined,\n cwd: string,\n importModule: ImportModule = (specifier) => import(specifier),\n exists: (path: string) => boolean = existsSync,\n): Promise<Capabilities[] | null> => {\n try {\n const file = findConfigFile(config, cwd, exists)\n if (!file) return null\n const loaded = (await importModule(pathToFileURL(file).href)) as ConfigModule | undefined\n const capabilities = (loaded?.config ?? loaded?.default?.config)?.capabilities\n return Array.isArray(capabilities)\n ? capabilities.map((entry: unknown) => (isRecord(entry) ? entry : {}))\n : null\n } catch {\n return null\n }\n}\n","import {\n buildIdempotencyKey,\n deliverRun,\n type FlakemetryDeliveryOptions,\n resolveRunContext,\n TestRunRecorder,\n} from '@flakemetry/sdk'\nimport WDIOReporterExport from '@wdio/reporter'\n\nimport { loadConfiguredCapabilities } from './capabilities'\nimport {\n type WdioAssertion,\n WdioCollector,\n type WdioCommand,\n type WdioHook,\n type WdioSuite,\n type WdioTest,\n} from './collector'\nimport {\n type Capabilities,\n resolveVariant,\n runFailed,\n shardOf,\n workerIdempotencyKey,\n workerOutputFile,\n} from './mapping'\n\nexport type FlakemetryWdioReporterOptions = FlakemetryDeliveryOptions\n\nexport interface WdioRunner {\n cid?: string\n specs?: string[]\n start?: Date\n end?: Date\n config?: unknown\n capabilities?: unknown\n isMultiremote?: boolean\n isMultiRemote?: boolean\n}\n\ninterface WdioReporterOptions extends FlakemetryWdioReporterOptions {\n logFile?: string\n outputDir?: string\n stdout?: boolean\n writeStream?: { write: (content: unknown) => boolean }\n}\n\nconst WDIOReporter = ((WDIOReporterExport as unknown as { default?: typeof WDIOReporterExport })\n .default ?? WDIOReporterExport) as typeof WDIOReporterExport\n\nconst SILENT = { write: (): boolean => true }\n\nconst asRecord = (value: unknown): Capabilities | undefined =>\n value && typeof value === 'object' && !Array.isArray(value) ? (value as Capabilities) : undefined\n\nconst deliveryOptions = (options: WdioReporterOptions): FlakemetryDeliveryOptions => {\n const { endpoint, token, outputFile, transport, bufferDir, sampleRate, rng } = options\n return { endpoint, token, outputFile, transport, bufferDir, sampleRate, rng }\n}\n\nexport default class FlakemetryWdioReporter extends WDIOReporter {\n private readonly delivery: FlakemetryDeliveryOptions\n private readonly env: Record<string, string | undefined>\n private readonly collector: WdioCollector\n private configured: Promise<Capabilities[] | null> = Promise.resolve(null)\n private startedAt: Date | undefined\n private delivering = false\n\n constructor(options: WdioReporterOptions = {}) {\n super({\n ...options,\n logFile: undefined,\n outputDir: undefined,\n writeStream: options.writeStream ?? SILENT,\n })\n this.delivery = deliveryOptions(options)\n this.env = process.env\n this.collector = new WdioCollector()\n }\n\n override get isSynchronised(): boolean {\n return !this.delivering\n }\n\n override onRunnerStart(runner: WdioRunner): void {\n this.guard(() => {\n this.startedAt = runner.start instanceof Date ? runner.start : new Date()\n this.collector.setSpecs(runner.specs)\n this.configured = loadConfiguredCapabilities(asRecord(runner.config), process.cwd())\n })\n }\n\n override onSuiteStart(suite: WdioSuite): void {\n this.guard(() => this.collector.suiteStart(suite))\n }\n\n override onSuiteEnd(suite: WdioSuite): void {\n this.guard(() => this.collector.suiteEnd(suite))\n }\n\n override onHookStart(hook: WdioHook): void {\n this.guard(() => this.collector.hookStart(hook))\n }\n\n override onHookEnd(hook: WdioHook): void {\n this.guard(() => this.collector.hookEnd(hook))\n }\n\n override onTestStart(test: WdioTest): void {\n this.guard(() => this.collector.testStart(test))\n }\n\n override onTestPass(test: WdioTest): void {\n this.guard(() => this.collector.testPass(test))\n }\n\n override onTestFail(test: WdioTest): void {\n this.guard(() => this.collector.testFail(test))\n }\n\n override onTestRetry(test: WdioTest): void {\n this.guard(() => this.collector.testRetry(test))\n }\n\n override onTestSkip(test: WdioTest): void {\n this.guard(() => this.collector.testSkip(test))\n }\n\n override onTestPending(test: WdioTest): void {\n this.guard(() => this.collector.testSkip(test))\n }\n\n override onTestEnd(test: WdioTest): void {\n this.guard(() => this.collector.testEnd(test))\n }\n\n override onBeforeCommand(command: WdioCommand): void {\n this.guard(() => this.collector.beforeCommand(command))\n }\n\n override onAfterCommand(command: WdioCommand): void {\n this.guard(() => this.collector.afterCommand(command))\n }\n\n override onBeforeAssertion(assertion: unknown): void {\n this.guard(() => this.collector.beforeAssertion(assertion as WdioAssertion))\n }\n\n override onAfterAssertion(assertion: unknown): void {\n this.guard(() => this.collector.afterAssertion(assertion as WdioAssertion))\n }\n\n override onRunnerEnd(runner: WdioRunner): void {\n this.delivering = true\n void this.deliver(runner).finally(() => {\n this.delivering = false\n })\n }\n\n private async deliver(runner: WdioRunner): Promise<void> {\n try {\n const config = asRecord(runner.config) ?? {}\n const rootDir = typeof config.rootDir === 'string' ? config.rootDir : process.cwd()\n const cid = runner.cid ?? this.env.WDIO_WORKER_ID ?? '0-0'\n const variant = resolveVariant({\n cid,\n requested: asRecord(config.capabilities) ?? asRecord(runner.capabilities),\n configured: await this.configured,\n multiremote: Boolean(runner.isMultiremote ?? runner.isMultiRemote),\n })\n const tests = this.collector.finish({ rootDir, variant })\n if (tests.length === 0) return\n\n const context = resolveRunContext(this.env, shardOf(config.shard))\n const recorder = new TestRunRecorder(context)\n recorder.startRun(this.startedAt ?? tests[0]?.startedAt ?? new Date())\n for (const test of tests) recorder.record(test)\n recorder.finishRun(\n runFailed(tests) ? 'failed' : 'passed',\n runner.end instanceof Date ? runner.end : new Date(),\n )\n\n const outputFile = this.delivery.outputFile ?? this.env.FLAKEMETRY_OUTPUT_FILE\n const idempotencyKey = workerIdempotencyKey(buildIdempotencyKey(context, this.env), cid)\n await deliverRun(\n recorder,\n idempotencyKey,\n {\n ...this.delivery,\n outputFile: outputFile ? workerOutputFile(outputFile, cid) : undefined,\n },\n this.env,\n rootDir,\n )\n } catch (error) {\n process.stderr.write(\n `flakemetry: the run was not delivered (${error instanceof Error ? error.message : String(error)})\\n`,\n )\n }\n }\n\n private guard(action: () => void): void {\n try {\n action()\n } catch (error) {\n process.stderr.write(\n `flakemetry: an event was not recorded (${error instanceof Error ? error.message : String(error)})\\n`,\n )\n }\n }\n}\n"],"mappings":";;;;;;;;AAgBA,MAAM,cAAc;AACpB,MAAM,qBAAqB;AAC3B,MAAM,qBAAqB;AAC3B,MAAM,6BAA6B;AAEnC,MAAM,UAAU,CACd,0CACA,gDACF;AAEA,MAAa,aAAa,UAA0B,yBAAyB,KAAK;AAElF,MAAa,WACX,QACA,UAC0B,QAAQ,MAAM,cAAc,QAAQ,SAAS,CAAC,KAAK,SAAS,KAAA;AAExF,MAAa,YAAY,UAA0C;CACjE,MAAM,UAAU,UAAU,OAAO,WAAW,EAAE,CAAC,CAAC,KAAK;CACrD,OAAO,QAAQ,MAAM,YAAY,QAAQ,KAAK,OAAO,CAAC;AACxD;AAEA,MAAa,kBACX,OACA,aACmE;CACnE,MAAM,QAAQ,UAAU,OAAO,WAAW,EAAE,CAAC,CAAC,MAAM,IAAI;CACxD,MAAM,QAAQ,MAAM,WAAW,SAAS,YAAY,KAAK,IAAI,CAAC;CAC9D,MAAM,WAAW,UAAU,KAAK,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,QAAQ,KAAK,UAAU,OAAO;IAAE;IAAS;GAAQ,CAAC;GACxD,IAAI,MAAM,WAAW,GAAG;GAExB,MAAM,UAAU,kBAAkB,KAAK,KAAK,QAAQ,OAAO,KAAK,CAAC;GACjE,MAAM,WAAW,IAAI,gBAAgB,OAAO;GAC5C,SAAS,SAAS,KAAK,aAAa,MAAM,EAAE,EAAE,6BAAa,IAAI,KAAK,CAAC;GACrE,KAAK,MAAM,QAAQ,OAAO,SAAS,OAAO,IAAI;GAC9C,SAAS,UACP,UAAU,KAAK,IAAI,WAAW,UAC9B,OAAO,eAAe,OAAO,OAAO,sBAAM,IAAI,KAAK,CACrD;GAEA,MAAM,aAAa,KAAK,SAAS,cAAc,KAAK,IAAI;GACxD,MAAM,iBAAiB,qBAAqB,oBAAoB,SAAS,KAAK,GAAG,GAAG,GAAG;GACvF,MAAM,WACJ,UACA,gBACA;IACE,GAAG,KAAK;IACR,YAAY,aAAa,iBAAiB,YAAY,GAAG,IAAI,KAAA;GAC/D,GACA,KAAK,KACL,OACF;EACF,SAAS,OAAO;GACd,QAAQ,OAAO,MACb,0CAA0C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE,IACnG;EACF;CACF;CAEA,MAAc,QAA0B;EACtC,IAAI;GACF,OAAO;EACT,SAAS,OAAO;GACd,QAAQ,OAAO,MACb,0CAA0C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE,IACnG;EACF;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,76 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flakemetry/wdio-reporter",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "WebdriverIO reporter emitting OpenTelemetry test spans to Flakemetry",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=22.15"
|
|
8
|
+
},
|
|
9
|
+
"author": "Andrii Kohut",
|
|
10
|
+
"homepage": "https://github.com/AKogut/flakemetry#readme",
|
|
11
|
+
"bugs": "https://github.com/AKogut/flakemetry/issues",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/AKogut/flakemetry.git",
|
|
15
|
+
"directory": "packages/wdio-reporter"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"webdriverio",
|
|
19
|
+
"wdio",
|
|
20
|
+
"wdio-reporter",
|
|
21
|
+
"appium",
|
|
22
|
+
"flaky-tests",
|
|
23
|
+
"opentelemetry"
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"type": "module",
|
|
29
|
+
"main": "./dist/index.cjs",
|
|
30
|
+
"module": "./dist/index.js",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"import": {
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"default": "./dist/index.js"
|
|
37
|
+
},
|
|
38
|
+
"require": {
|
|
39
|
+
"types": "./dist/index.d.cts",
|
|
40
|
+
"default": "./dist/index.cjs"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"./package.json": "./package.json"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"dist"
|
|
47
|
+
],
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/node": "^22.20.5",
|
|
50
|
+
"@vitest/coverage-v8": "^5.1.1",
|
|
51
|
+
"vitest": "^5.1.1",
|
|
52
|
+
"@flakemetry/build-config": "0.0.0",
|
|
53
|
+
"@flakemetry/tsconfig": "0.0.0",
|
|
54
|
+
"@flakemetry/eslint-config": "0.0.0"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@wdio/reporter": "^9.0.0 || ^10.0.0",
|
|
58
|
+
"@flakemetry/contracts": "0.6.0",
|
|
59
|
+
"@flakemetry/sdk": "0.4.1"
|
|
60
|
+
},
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"@wdio/cli": "^9.0.0 || ^10.0.0"
|
|
63
|
+
},
|
|
64
|
+
"peerDependenciesMeta": {
|
|
65
|
+
"@wdio/cli": {
|
|
66
|
+
"optional": true
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"scripts": {
|
|
70
|
+
"build": "tsdown --config-loader native",
|
|
71
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
72
|
+
"lint": "eslint .",
|
|
73
|
+
"clean": "rm -rf dist .turbo",
|
|
74
|
+
"test": "vitest run"
|
|
75
|
+
}
|
|
6
76
|
}
|