@fabricorg/databricks-bdd 0.1.0 → 0.3.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/dist/index.cjs CHANGED
@@ -6,6 +6,7 @@ var databricks = require('@fabric-harness/databricks');
6
6
  var child_process = require('child_process');
7
7
  var module$1 = require('module');
8
8
  var path = require('path');
9
+ var util = require('util');
9
10
 
10
11
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
11
12
  // src/world.ts
@@ -23,6 +24,7 @@ var DatabricksWorld = class extends cucumber.World {
23
24
  catalogOverride;
24
25
  lastSql;
25
26
  lastStatementId;
27
+ stepOutputCapture;
26
28
  lakebasePool;
27
29
  ctx;
28
30
  activeCtx;
@@ -76,6 +78,8 @@ var DatabricksWorld = class extends cucumber.World {
76
78
  this.schemaOverride = this.profile === "live" ? process.env.DBX_TEST_SCHEMA ?? schema : schema;
77
79
  }
78
80
  async dispose() {
81
+ this.stepOutputCapture?.stop();
82
+ this.stepOutputCapture = void 0;
79
83
  const errors = [];
80
84
  for (const cleanup of this.cleanups.splice(0).reverse()) {
81
85
  try {
@@ -239,6 +243,25 @@ function parseTableIdentifier(value) {
239
243
  }
240
244
  return identifier;
241
245
  }
246
+ var FAILURE_EVIDENCE_MEDIA_TYPE = "application/vnd.fabric.databricks-bdd.failure+json";
247
+ function parseFailureEvidenceAttachment(attachment) {
248
+ if (attachment.mediaType !== FAILURE_EVIDENCE_MEDIA_TYPE) return null;
249
+ try {
250
+ const body = attachment.contentEncoding === "BASE64" ? Buffer.from(attachment.body, "base64").toString("utf8") : attachment.body;
251
+ const parsed = JSON.parse(redactSecrets(body));
252
+ if (typeof parsed.step !== "string") return null;
253
+ return {
254
+ step: parsed.step,
255
+ ...typeof parsed.statementId === "string" ? { statementId: parsed.statementId } : {},
256
+ ...typeof parsed.sql === "string" ? { sql: parsed.sql } : {},
257
+ ...typeof parsed.output === "string" ? { output: parsed.output } : {},
258
+ ...typeof parsed.outputBytes === "number" ? { outputBytes: parsed.outputBytes } : {},
259
+ ...typeof parsed.outputTruncated === "boolean" ? { outputTruncated: parsed.outputTruncated } : {}
260
+ };
261
+ } catch {
262
+ return null;
263
+ }
264
+ }
242
265
  var SECRET_ENV_RE = /(TOKEN|SECRET|PASSWORD|BEARER|KEY)/;
243
266
  function redactSecrets(text, env = process.env) {
244
267
  let out = text;
@@ -249,18 +272,125 @@ function redactSecrets(text, env = process.env) {
249
272
  }
250
273
  return out;
251
274
  }
275
+ var DEFAULT_MAX_BYTES = 32 * 1024;
276
+ function startStepOutputCapture(options = {}) {
277
+ const maxBytes = Math.max(0, options.maxBytes ?? DEFAULT_MAX_BYTES);
278
+ const stdout = process.stdout;
279
+ const stderr = process.stderr;
280
+ const originalStdoutWrite = stdout.write;
281
+ const originalStderrWrite = stderr.write;
282
+ const originalConsole = Object.fromEntries(
283
+ ["debug", "error", "info", "log", "warn"].map((method) => [method, console[method]])
284
+ );
285
+ const chunks = [];
286
+ let retainedBytes = 0;
287
+ let totalBytes = 0;
288
+ let stopped = false;
289
+ const capture = (stream, chunk) => {
290
+ const text = chunkToString(chunk);
291
+ const bytes = Buffer.byteLength(text);
292
+ totalBytes += bytes;
293
+ const remaining = maxBytes - retainedBytes;
294
+ if (remaining <= 0 || bytes === 0) return;
295
+ const retained = bytes <= remaining ? text : truncateUtf8(text, remaining);
296
+ retainedBytes += Buffer.byteLength(retained);
297
+ if (retained) chunks.push({ stream, text: retained });
298
+ };
299
+ stdout.write = interceptedWrite(
300
+ stdout,
301
+ "stdout",
302
+ originalStdoutWrite,
303
+ capture,
304
+ options.passthrough
305
+ );
306
+ stderr.write = interceptedWrite(
307
+ stderr,
308
+ "stderr",
309
+ originalStderrWrite,
310
+ capture,
311
+ options.passthrough
312
+ );
313
+ if (!options.passthrough) {
314
+ for (const method of ["debug", "info", "log"]) {
315
+ console[method] = (...args) => capture("stdout", `${util.format(...args)}
316
+ `);
317
+ }
318
+ for (const method of ["error", "warn"]) {
319
+ console[method] = (...args) => capture("stderr", `${util.format(...args)}
320
+ `);
321
+ }
322
+ }
323
+ return {
324
+ stop() {
325
+ if (!stopped) {
326
+ stdout.write = originalStdoutWrite;
327
+ stderr.write = originalStderrWrite;
328
+ for (const method of Object.keys(originalConsole)) {
329
+ console[method] = originalConsole[method];
330
+ }
331
+ stopped = true;
332
+ }
333
+ return {
334
+ text: renderChunks(chunks),
335
+ truncated: totalBytes > retainedBytes,
336
+ totalBytes
337
+ };
338
+ }
339
+ };
340
+ }
341
+ function interceptedWrite(destination, stream, original, capture, passthrough = false) {
342
+ return function write(chunk, encodingOrCallback, callback) {
343
+ capture(stream, chunk);
344
+ if (passthrough) {
345
+ return original.call(
346
+ destination,
347
+ chunk,
348
+ encodingOrCallback,
349
+ callback
350
+ );
351
+ }
352
+ const done = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
353
+ if (typeof done === "function") queueMicrotask(() => done());
354
+ return true;
355
+ };
356
+ }
357
+ function chunkToString(chunk) {
358
+ if (typeof chunk === "string") return chunk;
359
+ if (Buffer.isBuffer(chunk)) return chunk.toString("utf8");
360
+ if (chunk instanceof Uint8Array) return Buffer.from(chunk).toString("utf8");
361
+ return String(chunk);
362
+ }
363
+ function truncateUtf8(value, maxBytes) {
364
+ return Buffer.from(value).subarray(0, maxBytes).toString("utf8").replace(/\uFFFD$/u, "");
365
+ }
366
+ function renderChunks(chunks) {
367
+ let rendered = "";
368
+ let previous;
369
+ for (const chunk of chunks) {
370
+ if (chunk.stream !== previous) {
371
+ if (rendered && !rendered.endsWith("\n")) rendered += "\n";
372
+ rendered += `[${chunk.stream}]
373
+ `;
374
+ previous = chunk.stream;
375
+ }
376
+ rendered += chunk.text;
377
+ }
378
+ return rendered.trimEnd();
379
+ }
252
380
 
253
381
  Object.defineProperty(exports, "waitForPipelineUpdate", {
254
382
  enumerable: true,
255
383
  get: function () { return databricksTestkit.waitForPipelineUpdate; }
256
384
  });
257
385
  exports.DatabricksWorld = DatabricksWorld;
386
+ exports.FAILURE_EVIDENCE_MEDIA_TYPE = FAILURE_EVIDENCE_MEDIA_TYPE;
258
387
  exports.LIVE_ONLY_TAGS = LIVE_ONLY_TAGS;
259
388
  exports.RUN_STATES = RUN_STATES;
260
389
  exports.coerceMatchRows = coerceMatchRows;
261
390
  exports.inferFixture = inferFixture;
262
391
  exports.liveOnlyReason = liveOnlyReason;
263
392
  exports.parseDuration = parseDuration;
393
+ exports.parseFailureEvidenceAttachment = parseFailureEvidenceAttachment;
264
394
  exports.parseTableIdentifier = parseTableIdentifier;
265
395
  exports.redactSecrets = redactSecrets;
266
396
  exports.resolveJobId = resolveJobId;
@@ -268,5 +398,6 @@ exports.resolvePipelineId = resolvePipelineId;
268
398
  exports.runFeatures = runFeatures;
269
399
  exports.runJobToTerminal = runJobToTerminal;
270
400
  exports.startPipelineUpdate = startPipelineUpdate;
401
+ exports.startStepOutputCapture = startStepOutputCapture;
271
402
  //# sourceMappingURL=index.cjs.map
272
403
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/world.ts","../src/profile.ts","../src/infer.ts","../src/jobs.ts","../src/pipelines.ts","../src/run-features.ts","../src/parameter-types.ts","../src/evidence-formatter.ts"],"names":["World","resolveProfile","createExecutionContext","waitForDatabricksRun","require","createRequire","join","dirname","execFile"],"mappings":";;;;;;;;;;;AAsBO,IAAM,eAAA,GAAN,cAA8BA,cAAA,CAAiC;AAAA,EAC3D,OAAA;AAAA;AAAA,EAET,QAAA,GAA6C,IAAA;AAAA;AAAA,EAE7C,SAAA,GAA0B,IAAA;AAAA;AAAA,EAE1B,OAAA,GAA0C,IAAA;AAAA;AAAA,EAE1C,kBAAA,GAAsE,IAAA;AAAA,EACtE,cAAA;AAAA,EACA,eAAA;AAAA,EACA,OAAA;AAAA,EACA,eAAA;AAAA,EACA,YAAA;AAAA,EAGQ,GAAA;AAAA,EACA,SAAA;AAAA,EACS,WAAsB,EAAC;AAAA,EAExC,YAAY,OAAA,E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,EAAK;AAC9B,EAAA,MAAM,IAAA,GAAO,oCAAA;AACb,EAAA,IAAI,CAAC,IAAI,MAAA,CAAO,CAAA,CAAA,EAAI,IAAI,CAAA,MAAA,EAAS,IAAI,CAAA,OAAA,CAAS,CAAA,CAAE,IAAA,CAAK,UAAU,CAAA,EAAG;AAChE,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,mCAAA,EAAsC,KAAK,CAAA,CAAA,CAAG,CAAA;AAAA,EAChE;AACA,EAAA,OAAO,UAAA;AACT;AC0FA,IAAM,aAAA,GAAgB,oCAAA;AAGf,SAAS,aAAA,CACd,IAAA,EACA,GAAA,GAA0C,OAAA,CAAQ,GAAA,EAC1C;AACR,EAAA,IAAI,GAAA,GAAM,IAAA;AACV,EAAA,KAAA,MAAW,CAAC,IAAA,EAAM,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,GAAG,CAAA,EAAG;AAC/C,IAAA,IAAI,CAAC,KAAA,IAAS,KAAA,CAAM,MAAA,GAAS,CAAA,EAAG;AAChC,IAAA,IAAI,CAAC,aAAA,CAAc,IAAA,CAAK,IAAI,CAAA,EAAG;AAC/B,IAAA,GAAA,GAAM,GAAA,CAAI,KAAA,CAAM,KAAK,CAAA,CAAE,KAAK,YAAY,CAAA;AAAA,EAC1C;AACA,EAAA,OAAO,GAAA;AACT","file":"index.cjs","sourcesContent":["import { type IWorldOptions, World } from '@cucumber/cucumber';\nimport {\n type ExecutionContext,\n type TestProfile,\n createExecutionContext,\n resolveProfile,\n} from '@fabricorg/databricks-testkit';\n\nexport interface DatabricksWorldParameters {\n /** Default schema for the execution context; overridable per scenario via the catalog/schema step. */\n schema?: string;\n /** Arbitrary typed runner configuration, comparable to behave `-D` userdata. */\n userdata?: Record<string, string | number | boolean>;\n}\n\ntype Cleanup = () => void | Promise<void>;\n\n/**\n * Cucumber World holding one ExecutionContext per scenario. The context is\n * created lazily on first use so `Given catalog ... and schema ...` can run\n * first; it is closed by the After hook registered in ./steps.ts.\n */\nexport class DatabricksWorld extends World<DatabricksWorldParameters> {\n readonly profile: TestProfile;\n /** Rows from the last `When I run the SQL` / `When I query table` step. */\n lastRows: Record<string, unknown>[] | null = null;\n /** Error captured from the last statement, for `Then the statement fails ...`. */\n lastError: Error | null = null;\n /** Terminal run record from the last `When I run job ...` step. */\n lastRun: Record<string, unknown> | null = null;\n /** Pipeline update handle from `When I start a full refresh of pipeline ...`. */\n lastPipelineUpdate: { pipelineId: string; updateId: string } | null = null;\n schemaOverride: string | undefined;\n catalogOverride: string | undefined;\n lastSql: string | undefined;\n lastStatementId: string | undefined;\n lakebasePool:\n | { query<T extends Record<string, unknown>>(sql: string): Promise<{ rows: T[] }> }\n | undefined;\n private ctx: ExecutionContext | undefined;\n private activeCtx: ExecutionContext | undefined;\n private readonly cleanups: Cleanup[] = [];\n\n constructor(options: IWorldOptions<DatabricksWorldParameters>) {\n super(options);\n this.profile = resolveProfile();\n }\n\n async context(): Promise<ExecutionContext> {\n if (this.activeCtx) return this.activeCtx;\n if (!this.ctx) {\n const env = this.catalogOverride\n ? { ...process.env, DBX_TEST_CATALOG: this.catalogOverride }\n : process.env;\n this.ctx = await createExecutionContext({\n profile: this.profile,\n env,\n schema: this.schemaOverride ?? this.parameters.schema,\n onStatement: ({ sql, statementId }) => {\n this.lastSql = sql;\n this.lastStatementId = statementId;\n },\n });\n }\n return this.ctx;\n }\n\n /** Route subsequent steps through a scenario-owned secondary identity. */\n useExecutionContext(context: ExecutionContext): void {\n if (this.activeCtx) throw new Error('A secondary execution context is already active');\n this.activeCtx = context;\n this.addCleanup(async () => {\n await context.close();\n this.activeCtx = undefined;\n });\n }\n\n /** Register scenario-scoped cleanup. Cleanups run in reverse order. */\n addCleanup(cleanup: Cleanup): void {\n this.cleanups.push(cleanup);\n }\n\n /** Resolve runner userdata from worldParameters first, then DBX_TEST_USERDATA_* env. */\n userdata(name: string): string | number | boolean | undefined {\n const configured = this.parameters.userdata?.[name];\n if (configured !== undefined) return configured;\n return process.env[`DBX_TEST_USERDATA_${name.replace(/[^A-Za-z0-9]/g, '_').toUpperCase()}`];\n }\n\n scopeTo(catalog: string, schema: string): void {\n if (this.ctx) {\n throw new Error(\n 'Given catalog/schema must run before any step that touches the warehouse in the scenario',\n );\n }\n // Feature files stay portable and readable with illustrative names. A live\n // runner may redirect every scenario into its provisioned scratch scope.\n this.catalogOverride =\n this.profile === 'live' ? (process.env.DBX_TEST_CATALOG ?? catalog) : catalog;\n this.schemaOverride =\n this.profile === 'live' ? (process.env.DBX_TEST_SCHEMA ?? schema) : schema;\n }\n\n async dispose(): Promise<void> {\n const errors: unknown[] = [];\n for (const cleanup of this.cleanups.splice(0).reverse()) {\n try {\n await cleanup();\n } catch (error) {\n errors.push(error);\n }\n }\n try {\n await this.ctx?.close();\n } catch (error) {\n errors.push(error);\n }\n this.ctx = undefined;\n if (errors.length > 0) throw new AggregateError(errors, 'Scenario cleanup failed');\n }\n}\n","import type { TestProfile } from '@fabricorg/databricks-testkit';\n\n/**\n * Tags that require a live workspace (or a long budget). Scenarios carrying\n * any of them are skipped under the `local` profile — see ADR-0006.\n */\nexport const LIVE_ONLY_TAGS = [\n '@live',\n '@jobs',\n '@dlt',\n '@pipeline',\n '@autoloader',\n '@lakebase',\n '@slow',\n] as const;\n\n/** Returns a skip reason when the scenario cannot run under the given profile, else null. */\nexport function liveOnlyReason(tags: readonly string[], profile: TestProfile): string | null {\n if (profile === 'live') return null;\n const blocking = tags.filter((t) => (LIVE_ONLY_TAGS as readonly string[]).includes(t));\n if (blocking.length === 0) return null;\n return `requires a live workspace (${blocking.join(', ')}); running under DBX_TEST_PROFILE=local`;\n}\n","import type { TableFixture } from '@fabricorg/databricks-testkit';\n\nconst INT_RE = /^-?\\d+$/;\nconst FLOAT_RE = /^-?\\d+\\.\\d+$/;\nconst TIMESTAMP_RE = /^\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}(:\\d{2})?/;\nconst BOOL_RE = /^(true|false)$/i;\n\n/**\n * Turn a Gherkin data table (header row + string cells) into a TableFixture,\n * inferring portable column types from the values: BIGINT, DOUBLE,\n * TIMESTAMP, BOOLEAN, else STRING. Empty cells become NULL.\n */\nexport function inferFixture(table: string, raw: readonly (readonly string[])[]): TableFixture {\n if (raw.length < 2) {\n throw new Error(`Data table for ${table} needs a header row and at least one data row`);\n }\n const [header, ...body] = raw as [readonly string[], ...(readonly string[])[]];\n const types = header.map((_, col) => inferColumnType(body.map((row) => row[col] ?? '')));\n const schema = header.map((name, i) => `\"${name}\" ${types[i]}`).join(', ');\n const rows = body.map((row) => row.map((cell, i) => coerceCell(cell, types[i] ?? 'STRING')));\n return { table, schema, rows };\n}\n\n/** Coerce data-table string cells to typed values for row matching (no header row). */\nexport function coerceMatchRows(raw: readonly (readonly string[])[]): Record<string, unknown>[] {\n if (raw.length < 2) {\n throw new Error('Match table needs a header row and at least one data row');\n }\n const [header, ...body] = raw as [readonly string[], ...(readonly string[])[]];\n return body.map((row) => {\n const out: Record<string, unknown> = {};\n header.forEach((name, i) => {\n out[name] = coerceCell(row[i] ?? '', inferColumnType([row[i] ?? '']));\n });\n return out;\n });\n}\n\nfunction inferColumnType(cells: readonly string[]): string {\n const present = cells.filter((c) => c !== '');\n if (present.length === 0) return 'STRING';\n if (present.every((c) => INT_RE.test(c))) return 'BIGINT';\n if (present.every((c) => FLOAT_RE.test(c) || INT_RE.test(c))) return 'DOUBLE';\n if (present.every((c) => TIMESTAMP_RE.test(c))) return 'TIMESTAMP';\n if (present.every((c) => BOOL_RE.test(c))) return 'BOOLEAN';\n return 'STRING';\n}\n\nfunction coerceCell(cell: string, type: string): unknown {\n if (cell === '') return null;\n if (type === 'BIGINT' || type === 'DOUBLE') return Number(cell);\n if (type === 'BOOLEAN') return /^true$/i.test(cell);\n return cell;\n}\n","import { type DatabricksRestClient, waitForDatabricksRun } from '@fabric-harness/databricks';\nimport type { WorkspaceClientLike } from '@fabricorg/databricks-testkit';\n\nexport interface RunJobOptions {\n pollIntervalMs?: number;\n timeoutMs?: number;\n}\n\nexport interface JobRunResult {\n runId: number;\n lifeCycleState: string;\n resultState: string;\n run: Record<string, unknown>;\n}\n\n/** Resolve a job by numeric id or by exact name via /api/2.1/jobs/list. */\nexport async function resolveJobId(client: WorkspaceClientLike, nameOrId: string): Promise<number> {\n if (/^\\d+$/.test(nameOrId)) return Number(nameOrId);\n const response = await client.get<{ jobs?: { job_id: number; settings?: { name?: string } }[] }>(\n '/api/2.1/jobs/list',\n { name: nameOrId },\n );\n const match = (response.jobs ?? []).find((j) => j.settings?.name === nameOrId);\n if (!match) throw new Error(`No Databricks job named '${nameOrId}' found`);\n return match.job_id;\n}\n\n/** run-now a job and poll its run to a terminal state. */\nexport async function runJobToTerminal(\n client: WorkspaceClientLike,\n nameOrId: string,\n options: RunJobOptions = {},\n): Promise<JobRunResult> {\n const jobId = await resolveJobId(client, nameOrId);\n const submitted = await client.post<{ run_id: number }>('/api/2.1/jobs/run-now', {\n job_id: jobId,\n });\n const run = await waitForDatabricksRun(client as DatabricksRestClient, submitted.run_id, {\n pollIntervalMs: options.pollIntervalMs,\n timeoutMs: options.timeoutMs,\n });\n const state = (run as { state?: { life_cycle_state?: string; result_state?: string } }).state;\n return {\n runId: submitted.run_id,\n lifeCycleState: state?.life_cycle_state ?? 'UNKNOWN',\n resultState: state?.result_state ?? 'UNKNOWN',\n run,\n };\n}\n","import {\n type PollOptions,\n type WorkspaceClientLike,\n waitForPipelineUpdate,\n} from '@fabricorg/databricks-testkit';\n\nexport type PipelineWaitOptions = PollOptions;\n\n/** Resolve a DLT/Lakeflow pipeline by id or exact name via /api/2.0/pipelines. */\nexport async function resolvePipelineId(\n client: WorkspaceClientLike,\n nameOrId: string,\n): Promise<string> {\n if (/^[0-9a-f]{8}-[0-9a-f-]{27,}$/i.test(nameOrId)) return nameOrId;\n const response = await client.get<{ statuses?: { pipeline_id: string; name?: string }[] }>(\n '/api/2.0/pipelines',\n { filter: `name LIKE '${nameOrId}'` },\n );\n const match = (response.statuses ?? []).find((p) => p.name === nameOrId);\n if (!match) throw new Error(`No Databricks pipeline named '${nameOrId}' found`);\n return match.pipeline_id;\n}\n\n/** Start a pipeline update; returns the update id to poll. */\nexport async function startPipelineUpdate(\n client: WorkspaceClientLike,\n pipelineId: string,\n options: { fullRefresh?: boolean } = {},\n): Promise<string> {\n const response = await client.post<{ update_id: string }>(\n `/api/2.0/pipelines/${encodeURIComponent(pipelineId)}/updates`,\n { full_refresh: options.fullRefresh ?? false },\n );\n return response.update_id;\n}\n\n/** Poll an update to a terminal state; throws on timeout or non-COMPLETED terminal states. */\nexport { waitForPipelineUpdate };\n","import { execFile } from 'node:child_process';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\n\nexport interface RunFeaturesOptions {\n /** Directory containing the cucumber config / features. */\n cwd: string;\n /** Extra CLI args, e.g. ['--tags', 'not @slow'] or ['features/foo.feature']. */\n args?: string[];\n /** Extra environment (merged over process.env). */\n env?: Record<string, string>;\n /** Load TypeScript support code via tsx (default true). */\n tsx?: boolean;\n timeoutMs?: number;\n}\n\nexport interface RunFeaturesResult {\n success: boolean;\n exitCode: number;\n output: string;\n}\n\n/**\n * Vitest bridge: run cucumber-js as a subprocess so feature suites can be\n * embedded in an existing vitest run (one CI entry point) without fighting\n * over cucumber's global step registry or vitest's module transforms.\n */\nexport async function runFeatures(options: RunFeaturesOptions): Promise<RunFeaturesResult> {\n const require = createRequire(import.meta.url);\n // The bin path is not in the package's exports map — resolve it relative\n // to package.json (which is exported).\n const pkgPath = require.resolve('@cucumber/cucumber/package.json');\n const pkg = require(pkgPath) as { bin: Record<string, string> };\n const bin = join(dirname(pkgPath), pkg.bin['cucumber-js'] ?? 'bin/cucumber.js');\n const env: NodeJS.ProcessEnv = { ...process.env, ...options.env };\n if (options.tsx ?? true) {\n const tsxImport = '--import tsx';\n env.NODE_OPTIONS = env.NODE_OPTIONS ? `${env.NODE_OPTIONS} ${tsxImport}` : tsxImport;\n }\n return new Promise((resolve) => {\n execFile(\n process.execPath,\n [bin, ...(options.args ?? [])],\n { cwd: options.cwd, env, timeout: options.timeoutMs ?? 120_000, maxBuffer: 16 * 1024 * 1024 },\n (error, stdout, stderr) => {\n const exitCode =\n error && typeof (error as { code?: unknown }).code === 'number'\n ? ((error as { code?: number }).code ?? 1)\n : error\n ? 1\n : 0;\n resolve({ success: exitCode === 0, exitCode, output: `${stdout}\\n${stderr}` });\n },\n );\n });\n}\n","import { defineParameterType } from '@cucumber/cucumber';\n\nexport const RUN_STATES = ['SUCCESS', 'FAILED', 'CANCELED', 'TIMEDOUT'] as const;\nexport type RunState = (typeof RUN_STATES)[number];\n\nexport function parseDuration(value: string): number {\n const match = value.trim().match(/^(\\d+(?:\\.\\d+)?)\\s*(milliseconds?|ms|seconds?|s|minutes?|m)$/i);\n if (!match) throw new Error(`Invalid duration '${value}'`);\n const amount = Number(match[1]);\n const unit = match[2]?.toLowerCase() ?? '';\n if (unit === 'ms' || unit.startsWith('millisecond')) return amount;\n if (unit === 's' || unit.startsWith('second')) return amount * 1_000;\n return amount * 60_000;\n}\n\nexport function parseTableIdentifier(value: string): string {\n const identifier = value.trim();\n const part = '(?:[A-Za-z_][A-Za-z0-9_]*|`[^`]+`)';\n if (!new RegExp(`^${part}(?:\\\\.${part}){0,2}$`).test(identifier)) {\n throw new Error(`Invalid 1-3 part table identifier '${value}'`);\n }\n return identifier;\n}\n\nexport function registerParameterTypes(): void {\n defineParameterType({\n name: 'runState',\n regexp: /SUCCESS|FAILED|CANCELED|TIMEDOUT/,\n transformer: (value: string): RunState => value as RunState,\n });\n\n defineParameterType({\n name: 'duration',\n regexp: /\\d+(?:\\.\\d+)?\\s*(?:milliseconds?|ms|seconds?|s|minutes?|m)/,\n transformer: parseDuration,\n });\n\n defineParameterType({\n name: 'table',\n regexp: /(?:[A-Za-z_][A-Za-z0-9_]*|`[^`]+`)(?:\\.(?:[A-Za-z_][A-Za-z0-9_]*|`[^`]+`)){0,2}/,\n transformer: parseTableIdentifier,\n });\n}\n","import { Formatter, type IFormatterOptions } from '@cucumber/cucumber';\n\n/**\n * Evidence formatter: schema-versioned, secret-redacted JSON summary of a\n * BDD run, shared in spirit with the live check runner's evidence output so\n * nightly runs double as audit artifacts. Wire it up in cucumber config:\n *\n * format: [['@fabricorg/databricks-bdd/evidence-formatter', 'reports/evidence.json']]\n */\nexport interface EvidenceScenario {\n name: string;\n uri: string;\n tags: string[];\n status: string;\n durationMs: number;\n error?: string;\n}\n\nexport interface EvidenceReport {\n schemaVersion: 1;\n kind: 'databricks-bdd';\n profile: string;\n finishedAt: string;\n success: boolean;\n summary: Record<string, number>;\n scenarios: EvidenceScenario[];\n}\n\ninterface Envelope {\n pickle?: { id: string; name: string; uri: string; tags?: { name: string }[] };\n testCase?: { id: string; pickleId: string };\n testCaseStarted?: { id: string; testCaseId: string };\n testStepFinished?: {\n testCaseStartedId: string;\n testStepResult: {\n status: string;\n message?: string;\n duration?: { seconds: number; nanos: number };\n };\n };\n testRunFinished?: { success?: boolean; timestamp?: { seconds: number; nanos: number } };\n}\n\nconst STATUS_RANK = ['UNKNOWN', 'PASSED', 'SKIPPED', 'PENDING', 'UNDEFINED', 'AMBIGUOUS', 'FAILED'];\n\nexport default class EvidenceFormatter extends Formatter {\n private readonly pickles = new Map<string, NonNullable<Envelope['pickle']>>();\n private readonly testCases = new Map<string, string>(); // testCaseId → pickleId\n private readonly attempts = new Map<\n string,\n { pickleId: string; status: string; durationMs: number; error?: string }\n >();\n\n constructor(options: IFormatterOptions) {\n super(options);\n options.eventBroadcaster.on('envelope', (envelope: Envelope) => this.onEnvelope(envelope));\n }\n\n private onEnvelope(envelope: Envelope): void {\n if (envelope.pickle) this.pickles.set(envelope.pickle.id, envelope.pickle);\n if (envelope.testCase) this.testCases.set(envelope.testCase.id, envelope.testCase.pickleId);\n if (envelope.testCaseStarted) {\n this.attempts.set(envelope.testCaseStarted.id, {\n pickleId: this.testCases.get(envelope.testCaseStarted.testCaseId) ?? '',\n status: 'UNKNOWN',\n durationMs: 0,\n });\n }\n if (envelope.testStepFinished) {\n const attempt = this.attempts.get(envelope.testStepFinished.testCaseStartedId);\n if (attempt) {\n const result = envelope.testStepFinished.testStepResult;\n if (STATUS_RANK.indexOf(result.status) > STATUS_RANK.indexOf(attempt.status)) {\n attempt.status = result.status;\n if (result.message) attempt.error = redactSecrets(result.message);\n }\n const d = result.duration;\n if (d) attempt.durationMs += d.seconds * 1000 + d.nanos / 1e6;\n }\n }\n if (envelope.testRunFinished) this.finish(envelope.testRunFinished);\n }\n\n private finish(finished: NonNullable<Envelope['testRunFinished']>): void {\n const scenarios: EvidenceScenario[] = [];\n const summary: Record<string, number> = {};\n for (const attempt of this.attempts.values()) {\n const pickle = this.pickles.get(attempt.pickleId);\n const status = attempt.status.toLowerCase();\n summary[status] = (summary[status] ?? 0) + 1;\n scenarios.push({\n name: pickle?.name ?? attempt.pickleId,\n uri: pickle?.uri ?? '',\n tags: (pickle?.tags ?? []).map((t) => t.name),\n status,\n durationMs: Math.round(attempt.durationMs),\n ...(attempt.error ? { error: attempt.error } : {}),\n });\n }\n const report: EvidenceReport = {\n schemaVersion: 1,\n kind: 'databricks-bdd',\n profile: process.env.DBX_TEST_PROFILE ?? 'local',\n finishedAt: new Date().toISOString(),\n success: finished.success ?? !scenarios.some((s) => s.status === 'failed'),\n summary,\n scenarios,\n };\n this.log(`${JSON.stringify(report, null, 2)}\\n`);\n }\n}\n\nconst SECRET_ENV_RE = /(TOKEN|SECRET|PASSWORD|BEARER|KEY)/;\n\n/** Replace values of secret-looking env vars anywhere they appear in text. */\nexport function redactSecrets(\n text: string,\n env: Record<string, string | undefined> = process.env,\n): string {\n let out = text;\n for (const [name, value] of Object.entries(env)) {\n if (!value || value.length < 6) continue;\n if (!SECRET_ENV_RE.test(name)) continue;\n out = out.split(value).join('[REDACTED]');\n }\n return out;\n}\n"]}
1
+ {"version":3,"sources":["../src/world.ts","../src/profile.ts","../src/infer.ts","../src/jobs.ts","../src/pipelines.ts","../src/run-features.ts","../src/parameter-types.ts","../src/evidence-formatter.ts","../src/output-capture.ts"],"names":["World","resolveProfile","createExecutionContext","waitForDatabricksRun","require","createRequire","join","dirname","execFile","format"],"mappings":";;;;;;;;;;;;AAuBO,IAAM,eAAA,GAAN,cAA8BA,cAAA,CAAiC;AAAA,EAC3D,OAAA;AAAA;AAAA,EAET,QAAA,GAA6C,IAAA;AAAA;AAAA,EAE7C,SAAA,GAA0B,IAAA;AAAA;AAAA,EAE1B,OAAA,GAA0C,IAAA;AAAA;AAAA,EAE1C,kBAAA,GAAsE,IAAA;AAAA,EACtE,cAAA;AAAA,EACA,eAAA;AAAA,EACA,OAAA;AAAA,EACA,eAAA;AAAA,EACA,iBAAA;AAAA,EACA,YAAA;AAAA,EAGQ,GAAA;AAAA,EACA,SAAA;AAAA,EACS,WAAsB,EAAC;AAAA,EAExC,YAAY,OAAA,EAAmD;AAC7D,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,UAAUC,gCAAA,EAAe;AAAA,EAChC;AAAA,EAEA,MAAM,OAAA,GAAqC;AACzC,IAAA,IAAI,IAAA,CAAK,SAAA,EAAW,OAAO,IAAA,CAAK,SAAA;AAChC,IAAA,IAAI,CAAC,KAAK,GAAA,EAAK;AACb,MAAA,MAAM,GAAA,GAAM,IAAA,CAAK,eAAA,GACb,EAAE,GAAG,OAAA,CAAQ,GAAA,EAAK,gBAAA,EAAkB,IAAA,CAAK,eAAA,EAAgB,GACzD,OAAA,CAAQ,GAAA;AACZ,MAAA,IAAA,CAAK,GAAA,GAAM,MAAMC,wCAAA,CAAuB;AAAA,QACtC,SAAS,IAAA,CAAK,OAAA;AAAA,QACd,GAAA;AAAA,QACA,MAAA,EAAQ,IAAA,CAAK,cAAA,IAAkB,IAAA,CAAK,UAAA,CAAW,MAAA;AAAA,QAC/C,WAAA,EAAa,CAAC,EAAE,GAAA,EAAK,aAAY,KAAM;AACrC,UAAA,IAAA,CAAK,OAAA,GAAU,GAAA;AACf,UAAA,IAAA,CAAK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Ae,QAAA,EAA0B;AAC7D,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,CACrB,QAAA,CAAS,CAAA,EAAG,QAAQ,CAAA,CACpB,QAAA,CAAS,MAAM,CAAA,CACf,OAAA,CAAQ,YAAY,EAAE,CAAA;AAC3B;AAEA,SAAS,aAAa,MAAA,EAA0C;AAC9D,EAAA,IAAI,QAAA,GAAW,EAAA;AACf,EAAA,IAAI,QAAA;AACJ,EAAA,KAAA,MAAW,SAAS,MAAA,EAAQ;AAC1B,IAAA,IAAI,KAAA,CAAM,WAAW,QAAA,EAAU;AAC7B,MAAA,IAAI,YAAY,CAAC,QAAA,CAAS,QAAA,CAAS,IAAI,GAAG,QAAA,IAAY,IAAA;AACtD,MAAA,QAAA,IAAY,CAAA,CAAA,EAAI,MAAM,MAAM,CAAA;AAAA,CAAA;AAC5B,MAAA,QAAA,GAAW,KAAA,CAAM,MAAA;AAAA,IACnB;AACA,IAAA,QAAA,IAAY,KAAA,CAAM,IAAA;AAAA,EACpB;AACA,EAAA,OAAO,SAAS,OAAA,EAAQ;AAC1B","file":"index.cjs","sourcesContent":["import { type IWorldOptions, World } from '@cucumber/cucumber';\nimport {\n type ExecutionContext,\n type TestProfile,\n createExecutionContext,\n resolveProfile,\n} from '@fabricorg/databricks-testkit';\nimport type { StepOutputCapture } from './output-capture.js';\n\nexport interface DatabricksWorldParameters {\n /** Default schema for the execution context; overridable per scenario via the catalog/schema step. */\n schema?: string;\n /** Arbitrary typed runner configuration, comparable to behave `-D` userdata. */\n userdata?: Record<string, string | number | boolean>;\n}\n\ntype Cleanup = () => void | Promise<void>;\n\n/**\n * Cucumber World holding one ExecutionContext per scenario. The context is\n * created lazily on first use so `Given catalog ... and schema ...` can run\n * first; it is closed by the After hook registered in ./steps.ts.\n */\nexport class DatabricksWorld extends World<DatabricksWorldParameters> {\n readonly profile: TestProfile;\n /** Rows from the last `When I run the SQL` / `When I query table` step. */\n lastRows: Record<string, unknown>[] | null = null;\n /** Error captured from the last statement, for `Then the statement fails ...`. */\n lastError: Error | null = null;\n /** Terminal run record from the last `When I run job ...` step. */\n lastRun: Record<string, unknown> | null = null;\n /** Pipeline update handle from `When I start a full refresh of pipeline ...`. */\n lastPipelineUpdate: { pipelineId: string; updateId: string } | null = null;\n schemaOverride: string | undefined;\n catalogOverride: string | undefined;\n lastSql: string | undefined;\n lastStatementId: string | undefined;\n stepOutputCapture: StepOutputCapture | undefined;\n lakebasePool:\n | { query<T extends Record<string, unknown>>(sql: string): Promise<{ rows: T[] }> }\n | undefined;\n private ctx: ExecutionContext | undefined;\n private activeCtx: ExecutionContext | undefined;\n private readonly cleanups: Cleanup[] = [];\n\n constructor(options: IWorldOptions<DatabricksWorldParameters>) {\n super(options);\n this.profile = resolveProfile();\n }\n\n async context(): Promise<ExecutionContext> {\n if (this.activeCtx) return this.activeCtx;\n if (!this.ctx) {\n const env = this.catalogOverride\n ? { ...process.env, DBX_TEST_CATALOG: this.catalogOverride }\n : process.env;\n this.ctx = await createExecutionContext({\n profile: this.profile,\n env,\n schema: this.schemaOverride ?? this.parameters.schema,\n onStatement: ({ sql, statementId }) => {\n this.lastSql = sql;\n this.lastStatementId = statementId;\n },\n });\n }\n return this.ctx;\n }\n\n /** Route subsequent steps through a scenario-owned secondary identity. */\n useExecutionContext(context: ExecutionContext): void {\n if (this.activeCtx) throw new Error('A secondary execution context is already active');\n this.activeCtx = context;\n this.addCleanup(async () => {\n await context.close();\n this.activeCtx = undefined;\n });\n }\n\n /** Register scenario-scoped cleanup. Cleanups run in reverse order. */\n addCleanup(cleanup: Cleanup): void {\n this.cleanups.push(cleanup);\n }\n\n /** Resolve runner userdata from worldParameters first, then DBX_TEST_USERDATA_* env. */\n userdata(name: string): string | number | boolean | undefined {\n const configured = this.parameters.userdata?.[name];\n if (configured !== undefined) return configured;\n return process.env[`DBX_TEST_USERDATA_${name.replace(/[^A-Za-z0-9]/g, '_').toUpperCase()}`];\n }\n\n scopeTo(catalog: string, schema: string): void {\n if (this.ctx) {\n throw new Error(\n 'Given catalog/schema must run before any step that touches the warehouse in the scenario',\n );\n }\n // Feature files stay portable and readable with illustrative names. A live\n // runner may redirect every scenario into its provisioned scratch scope.\n this.catalogOverride =\n this.profile === 'live' ? (process.env.DBX_TEST_CATALOG ?? catalog) : catalog;\n this.schemaOverride =\n this.profile === 'live' ? (process.env.DBX_TEST_SCHEMA ?? schema) : schema;\n }\n\n async dispose(): Promise<void> {\n this.stepOutputCapture?.stop();\n this.stepOutputCapture = undefined;\n const errors: unknown[] = [];\n for (const cleanup of this.cleanups.splice(0).reverse()) {\n try {\n await cleanup();\n } catch (error) {\n errors.push(error);\n }\n }\n try {\n await this.ctx?.close();\n } catch (error) {\n errors.push(error);\n }\n this.ctx = undefined;\n if (errors.length > 0) throw new AggregateError(errors, 'Scenario cleanup failed');\n }\n}\n","import type { TestProfile } from '@fabricorg/databricks-testkit';\n\n/**\n * Tags that require a live workspace (or a long budget). Scenarios carrying\n * any of them are skipped under the `local` profile — see ADR-0006.\n */\nexport const LIVE_ONLY_TAGS = [\n '@live',\n '@jobs',\n '@dlt',\n '@pipeline',\n '@autoloader',\n '@lakebase',\n '@slow',\n] as const;\n\n/** Returns a skip reason when the scenario cannot run under the given profile, else null. */\nexport function liveOnlyReason(tags: readonly string[], profile: TestProfile): string | null {\n if (profile === 'live') return null;\n const blocking = tags.filter((t) => (LIVE_ONLY_TAGS as readonly string[]).includes(t));\n if (blocking.length === 0) return null;\n return `requires a live workspace (${blocking.join(', ')}); running under DBX_TEST_PROFILE=local`;\n}\n","import type { TableFixture } from '@fabricorg/databricks-testkit';\n\nconst INT_RE = /^-?\\d+$/;\nconst FLOAT_RE = /^-?\\d+\\.\\d+$/;\nconst TIMESTAMP_RE = /^\\d{4}-\\d{2}-\\d{2}[T ]\\d{2}:\\d{2}(:\\d{2})?/;\nconst BOOL_RE = /^(true|false)$/i;\n\n/**\n * Turn a Gherkin data table (header row + string cells) into a TableFixture,\n * inferring portable column types from the values: BIGINT, DOUBLE,\n * TIMESTAMP, BOOLEAN, else STRING. Empty cells become NULL.\n */\nexport function inferFixture(table: string, raw: readonly (readonly string[])[]): TableFixture {\n if (raw.length < 2) {\n throw new Error(`Data table for ${table} needs a header row and at least one data row`);\n }\n const [header, ...body] = raw as [readonly string[], ...(readonly string[])[]];\n const types = header.map((_, col) => inferColumnType(body.map((row) => row[col] ?? '')));\n const schema = header.map((name, i) => `\"${name}\" ${types[i]}`).join(', ');\n const rows = body.map((row) => row.map((cell, i) => coerceCell(cell, types[i] ?? 'STRING')));\n return { table, schema, rows };\n}\n\n/** Coerce data-table string cells to typed values for row matching (no header row). */\nexport function coerceMatchRows(raw: readonly (readonly string[])[]): Record<string, unknown>[] {\n if (raw.length < 2) {\n throw new Error('Match table needs a header row and at least one data row');\n }\n const [header, ...body] = raw as [readonly string[], ...(readonly string[])[]];\n return body.map((row) => {\n const out: Record<string, unknown> = {};\n header.forEach((name, i) => {\n out[name] = coerceCell(row[i] ?? '', inferColumnType([row[i] ?? '']));\n });\n return out;\n });\n}\n\nfunction inferColumnType(cells: readonly string[]): string {\n const present = cells.filter((c) => c !== '');\n if (present.length === 0) return 'STRING';\n if (present.every((c) => INT_RE.test(c))) return 'BIGINT';\n if (present.every((c) => FLOAT_RE.test(c) || INT_RE.test(c))) return 'DOUBLE';\n if (present.every((c) => TIMESTAMP_RE.test(c))) return 'TIMESTAMP';\n if (present.every((c) => BOOL_RE.test(c))) return 'BOOLEAN';\n return 'STRING';\n}\n\nfunction coerceCell(cell: string, type: string): unknown {\n if (cell === '') return null;\n if (type === 'BIGINT' || type === 'DOUBLE') return Number(cell);\n if (type === 'BOOLEAN') return /^true$/i.test(cell);\n return cell;\n}\n","import { type DatabricksRestClient, waitForDatabricksRun } from '@fabric-harness/databricks';\nimport type { WorkspaceClientLike } from '@fabricorg/databricks-testkit';\n\nexport interface RunJobOptions {\n pollIntervalMs?: number;\n timeoutMs?: number;\n}\n\nexport interface JobRunResult {\n runId: number;\n lifeCycleState: string;\n resultState: string;\n run: Record<string, unknown>;\n}\n\n/** Resolve a job by numeric id or by exact name via /api/2.1/jobs/list. */\nexport async function resolveJobId(client: WorkspaceClientLike, nameOrId: string): Promise<number> {\n if (/^\\d+$/.test(nameOrId)) return Number(nameOrId);\n const response = await client.get<{ jobs?: { job_id: number; settings?: { name?: string } }[] }>(\n '/api/2.1/jobs/list',\n { name: nameOrId },\n );\n const match = (response.jobs ?? []).find((j) => j.settings?.name === nameOrId);\n if (!match) throw new Error(`No Databricks job named '${nameOrId}' found`);\n return match.job_id;\n}\n\n/** run-now a job and poll its run to a terminal state. */\nexport async function runJobToTerminal(\n client: WorkspaceClientLike,\n nameOrId: string,\n options: RunJobOptions = {},\n): Promise<JobRunResult> {\n const jobId = await resolveJobId(client, nameOrId);\n const submitted = await client.post<{ run_id: number }>('/api/2.1/jobs/run-now', {\n job_id: jobId,\n });\n const run = await waitForDatabricksRun(client as DatabricksRestClient, submitted.run_id, {\n pollIntervalMs: options.pollIntervalMs,\n timeoutMs: options.timeoutMs,\n });\n const state = (run as { state?: { life_cycle_state?: string; result_state?: string } }).state;\n return {\n runId: submitted.run_id,\n lifeCycleState: state?.life_cycle_state ?? 'UNKNOWN',\n resultState: state?.result_state ?? 'UNKNOWN',\n run,\n };\n}\n","import {\n type PollOptions,\n type WorkspaceClientLike,\n waitForPipelineUpdate,\n} from '@fabricorg/databricks-testkit';\n\nexport type PipelineWaitOptions = PollOptions;\n\n/** Resolve a DLT/Lakeflow pipeline by id or exact name via /api/2.0/pipelines. */\nexport async function resolvePipelineId(\n client: WorkspaceClientLike,\n nameOrId: string,\n): Promise<string> {\n if (/^[0-9a-f]{8}-[0-9a-f-]{27,}$/i.test(nameOrId)) return nameOrId;\n const response = await client.get<{ statuses?: { pipeline_id: string; name?: string }[] }>(\n '/api/2.0/pipelines',\n { filter: `name LIKE '${nameOrId}'` },\n );\n const match = (response.statuses ?? []).find((p) => p.name === nameOrId);\n if (!match) throw new Error(`No Databricks pipeline named '${nameOrId}' found`);\n return match.pipeline_id;\n}\n\n/** Start a pipeline update; returns the update id to poll. */\nexport async function startPipelineUpdate(\n client: WorkspaceClientLike,\n pipelineId: string,\n options: { fullRefresh?: boolean } = {},\n): Promise<string> {\n const response = await client.post<{ update_id: string }>(\n `/api/2.0/pipelines/${encodeURIComponent(pipelineId)}/updates`,\n { full_refresh: options.fullRefresh ?? false },\n );\n return response.update_id;\n}\n\n/** Poll an update to a terminal state; throws on timeout or non-COMPLETED terminal states. */\nexport { waitForPipelineUpdate };\n","import { execFile } from 'node:child_process';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\n\nexport interface RunFeaturesOptions {\n /** Directory containing the cucumber config / features. */\n cwd: string;\n /** Extra CLI args, e.g. ['--tags', 'not @slow'] or ['features/foo.feature']. */\n args?: string[];\n /** Extra environment (merged over process.env). */\n env?: Record<string, string>;\n /** Load TypeScript support code via tsx (default true). */\n tsx?: boolean;\n timeoutMs?: number;\n}\n\nexport interface RunFeaturesResult {\n success: boolean;\n exitCode: number;\n output: string;\n}\n\n/**\n * Vitest bridge: run cucumber-js as a subprocess so feature suites can be\n * embedded in an existing vitest run (one CI entry point) without fighting\n * over cucumber's global step registry or vitest's module transforms.\n */\nexport async function runFeatures(options: RunFeaturesOptions): Promise<RunFeaturesResult> {\n const require = createRequire(import.meta.url);\n // The bin path is not in the package's exports map — resolve it relative\n // to package.json (which is exported).\n const pkgPath = require.resolve('@cucumber/cucumber/package.json');\n const pkg = require(pkgPath) as { bin: Record<string, string> };\n const bin = join(dirname(pkgPath), pkg.bin['cucumber-js'] ?? 'bin/cucumber.js');\n const env: NodeJS.ProcessEnv = { ...process.env, ...options.env };\n if (options.tsx ?? true) {\n const tsxImport = '--import tsx';\n env.NODE_OPTIONS = env.NODE_OPTIONS ? `${env.NODE_OPTIONS} ${tsxImport}` : tsxImport;\n }\n return new Promise((resolve) => {\n execFile(\n process.execPath,\n [bin, ...(options.args ?? [])],\n { cwd: options.cwd, env, timeout: options.timeoutMs ?? 120_000, maxBuffer: 16 * 1024 * 1024 },\n (error, stdout, stderr) => {\n const exitCode =\n error && typeof (error as { code?: unknown }).code === 'number'\n ? ((error as { code?: number }).code ?? 1)\n : error\n ? 1\n : 0;\n resolve({ success: exitCode === 0, exitCode, output: `${stdout}\\n${stderr}` });\n },\n );\n });\n}\n","import { defineParameterType } from '@cucumber/cucumber';\n\nexport const RUN_STATES = ['SUCCESS', 'FAILED', 'CANCELED', 'TIMEDOUT'] as const;\nexport type RunState = (typeof RUN_STATES)[number];\n\nexport function parseDuration(value: string): number {\n const match = value.trim().match(/^(\\d+(?:\\.\\d+)?)\\s*(milliseconds?|ms|seconds?|s|minutes?|m)$/i);\n if (!match) throw new Error(`Invalid duration '${value}'`);\n const amount = Number(match[1]);\n const unit = match[2]?.toLowerCase() ?? '';\n if (unit === 'ms' || unit.startsWith('millisecond')) return amount;\n if (unit === 's' || unit.startsWith('second')) return amount * 1_000;\n return amount * 60_000;\n}\n\nexport function parseTableIdentifier(value: string): string {\n const identifier = value.trim();\n const part = '(?:[A-Za-z_][A-Za-z0-9_]*|`[^`]+`)';\n if (!new RegExp(`^${part}(?:\\\\.${part}){0,2}$`).test(identifier)) {\n throw new Error(`Invalid 1-3 part table identifier '${value}'`);\n }\n return identifier;\n}\n\nexport function registerParameterTypes(): void {\n defineParameterType({\n name: 'runState',\n regexp: /SUCCESS|FAILED|CANCELED|TIMEDOUT/,\n transformer: (value: string): RunState => value as RunState,\n });\n\n defineParameterType({\n name: 'duration',\n regexp: /\\d+(?:\\.\\d+)?\\s*(?:milliseconds?|ms|seconds?|s|minutes?|m)/,\n transformer: parseDuration,\n });\n\n defineParameterType({\n name: 'table',\n regexp: /(?:[A-Za-z_][A-Za-z0-9_]*|`[^`]+`)(?:\\.(?:[A-Za-z_][A-Za-z0-9_]*|`[^`]+`)){0,2}/,\n transformer: parseTableIdentifier,\n });\n}\n","import { Formatter, type IFormatterOptions } from '@cucumber/cucumber';\n\n/**\n * Evidence formatter: schema-versioned, secret-redacted JSON summary of a\n * BDD run, shared in spirit with the live check runner's evidence output so\n * nightly runs double as audit artifacts. Wire it up in cucumber config:\n *\n * format: [['@fabricorg/databricks-bdd/evidence-formatter', 'reports/evidence.json']]\n */\nexport interface EvidenceScenario {\n name: string;\n uri: string;\n tags: string[];\n status: string;\n durationMs: number;\n error?: string;\n failures?: StepFailureEvidence[];\n}\n\nexport interface StepFailureEvidence {\n step: string;\n statementId?: string;\n sql?: string;\n output?: string;\n outputBytes?: number;\n outputTruncated?: boolean;\n}\n\nexport interface EvidenceReport {\n schemaVersion: 2;\n kind: 'databricks-bdd';\n profile: string;\n finishedAt: string;\n success: boolean;\n summary: Record<string, number>;\n scenarios: EvidenceScenario[];\n}\n\ninterface Envelope {\n attachment?: {\n body: string;\n contentEncoding: 'IDENTITY' | 'BASE64';\n mediaType: string;\n testCaseStartedId?: string;\n };\n pickle?: { id: string; name: string; uri: string; tags?: { name: string }[] };\n testCase?: { id: string; pickleId: string };\n testCaseStarted?: { id: string; testCaseId: string };\n testStepFinished?: {\n testCaseStartedId: string;\n testStepResult: {\n status: string;\n message?: string;\n duration?: { seconds: number; nanos: number };\n };\n };\n testRunFinished?: { success?: boolean; timestamp?: { seconds: number; nanos: number } };\n}\n\nexport const FAILURE_EVIDENCE_MEDIA_TYPE = 'application/vnd.fabric.databricks-bdd.failure+json';\n\nconst STATUS_RANK = ['UNKNOWN', 'PASSED', 'SKIPPED', 'PENDING', 'UNDEFINED', 'AMBIGUOUS', 'FAILED'];\n\nexport default class EvidenceFormatter extends Formatter {\n private readonly pickles = new Map<string, NonNullable<Envelope['pickle']>>();\n private readonly testCases = new Map<string, string>(); // testCaseId → pickleId\n private readonly attempts = new Map<\n string,\n {\n pickleId: string;\n status: string;\n durationMs: number;\n error?: string;\n failures: StepFailureEvidence[];\n }\n >();\n\n constructor(options: IFormatterOptions) {\n super(options);\n options.eventBroadcaster.on('envelope', (envelope: Envelope) => this.onEnvelope(envelope));\n }\n\n private onEnvelope(envelope: Envelope): void {\n if (envelope.pickle) this.pickles.set(envelope.pickle.id, envelope.pickle);\n if (envelope.testCase) this.testCases.set(envelope.testCase.id, envelope.testCase.pickleId);\n if (envelope.testCaseStarted) {\n this.attempts.set(envelope.testCaseStarted.id, {\n pickleId: this.testCases.get(envelope.testCaseStarted.testCaseId) ?? '',\n status: 'UNKNOWN',\n durationMs: 0,\n failures: [],\n });\n }\n if (envelope.attachment?.testCaseStartedId) {\n const attempt = this.attempts.get(envelope.attachment.testCaseStartedId);\n const failure = parseFailureEvidenceAttachment(envelope.attachment);\n if (attempt && failure) attempt.failures.push(failure);\n }\n if (envelope.testStepFinished) {\n const attempt = this.attempts.get(envelope.testStepFinished.testCaseStartedId);\n if (attempt) {\n const result = envelope.testStepFinished.testStepResult;\n if (STATUS_RANK.indexOf(result.status) > STATUS_RANK.indexOf(attempt.status)) {\n attempt.status = result.status;\n if (result.message) attempt.error = redactSecrets(result.message);\n }\n const d = result.duration;\n if (d) attempt.durationMs += d.seconds * 1000 + d.nanos / 1e6;\n }\n }\n if (envelope.testRunFinished) this.finish(envelope.testRunFinished);\n }\n\n private finish(finished: NonNullable<Envelope['testRunFinished']>): void {\n const scenarios: EvidenceScenario[] = [];\n const summary: Record<string, number> = {};\n for (const attempt of this.attempts.values()) {\n const pickle = this.pickles.get(attempt.pickleId);\n const status = attempt.status.toLowerCase();\n summary[status] = (summary[status] ?? 0) + 1;\n scenarios.push({\n name: pickle?.name ?? attempt.pickleId,\n uri: pickle?.uri ?? '',\n tags: (pickle?.tags ?? []).map((t) => t.name),\n status,\n durationMs: Math.round(attempt.durationMs),\n ...(attempt.error ? { error: attempt.error } : {}),\n ...(attempt.failures.length > 0 ? { failures: attempt.failures } : {}),\n });\n }\n const report: EvidenceReport = {\n schemaVersion: 2,\n kind: 'databricks-bdd',\n profile: process.env.DBX_TEST_PROFILE ?? 'local',\n finishedAt: new Date().toISOString(),\n success: finished.success ?? !scenarios.some((s) => s.status === 'failed'),\n summary,\n scenarios,\n };\n this.log(`${JSON.stringify(report, null, 2)}\\n`);\n }\n}\n\n/** Decode the structured attachment emitted by the failure hook. */\nexport function parseFailureEvidenceAttachment(\n attachment: NonNullable<Envelope['attachment']>,\n): StepFailureEvidence | null {\n if (attachment.mediaType !== FAILURE_EVIDENCE_MEDIA_TYPE) return null;\n try {\n const body =\n attachment.contentEncoding === 'BASE64'\n ? Buffer.from(attachment.body, 'base64').toString('utf8')\n : attachment.body;\n const parsed = JSON.parse(redactSecrets(body)) as Partial<StepFailureEvidence>;\n if (typeof parsed.step !== 'string') return null;\n return {\n step: parsed.step,\n ...(typeof parsed.statementId === 'string' ? { statementId: parsed.statementId } : {}),\n ...(typeof parsed.sql === 'string' ? { sql: parsed.sql } : {}),\n ...(typeof parsed.output === 'string' ? { output: parsed.output } : {}),\n ...(typeof parsed.outputBytes === 'number' ? { outputBytes: parsed.outputBytes } : {}),\n ...(typeof parsed.outputTruncated === 'boolean'\n ? { outputTruncated: parsed.outputTruncated }\n : {}),\n };\n } catch {\n return null;\n }\n}\n\nconst SECRET_ENV_RE = /(TOKEN|SECRET|PASSWORD|BEARER|KEY)/;\n\n/** Replace values of secret-looking env vars anywhere they appear in text. */\nexport function redactSecrets(\n text: string,\n env: Record<string, string | undefined> = process.env,\n): string {\n let out = text;\n for (const [name, value] of Object.entries(env)) {\n if (!value || value.length < 6) continue;\n if (!SECRET_ENV_RE.test(name)) continue;\n out = out.split(value).join('[REDACTED]');\n }\n return out;\n}\n","import type { Writable } from 'node:stream';\nimport { format } from 'node:util';\n\nexport type CapturedStream = 'stdout' | 'stderr';\n\nexport interface CapturedStepOutput {\n /** Ordered stdout/stderr output with stream labels. */\n text: string;\n /** True when output exceeded the configured byte budget. */\n truncated: boolean;\n /** Total bytes emitted before truncation. */\n totalBytes: number;\n}\n\nexport interface StepOutputCapture {\n stop(): CapturedStepOutput;\n}\n\nexport interface StepOutputCaptureOptions {\n /** Maximum UTF-8 bytes retained for one step. Defaults to 32 KiB. */\n maxBytes?: number;\n /** Forward output while capturing. Defaults to false, matching Behave capture semantics. */\n passthrough?: boolean;\n}\n\ninterface CapturedChunk {\n stream: CapturedStream;\n text: string;\n}\n\ntype Write = Writable['write'];\ntype ConsoleMethod = 'debug' | 'error' | 'info' | 'log' | 'warn';\n\nconst DEFAULT_MAX_BYTES = 32 * 1024;\n\n/**\n * Capture process stdout/stderr until stop() is called. Console output and\n * Pino's standard destination both flow through these streams. Child\n * processes that inherit the OS file descriptors directly are intentionally\n * outside this in-process capture boundary.\n */\nexport function startStepOutputCapture(options: StepOutputCaptureOptions = {}): StepOutputCapture {\n const maxBytes = Math.max(0, options.maxBytes ?? DEFAULT_MAX_BYTES);\n const stdout = process.stdout;\n const stderr = process.stderr;\n const originalStdoutWrite = stdout.write;\n const originalStderrWrite = stderr.write;\n const originalConsole = Object.fromEntries(\n (['debug', 'error', 'info', 'log', 'warn'] as const).map((method) => [method, console[method]]),\n ) as Record<ConsoleMethod, typeof console.log>;\n const chunks: CapturedChunk[] = [];\n let retainedBytes = 0;\n let totalBytes = 0;\n let stopped = false;\n\n const capture = (stream: CapturedStream, chunk: unknown): void => {\n const text = chunkToString(chunk);\n const bytes = Buffer.byteLength(text);\n totalBytes += bytes;\n const remaining = maxBytes - retainedBytes;\n if (remaining <= 0 || bytes === 0) return;\n const retained = bytes <= remaining ? text : truncateUtf8(text, remaining);\n retainedBytes += Buffer.byteLength(retained);\n if (retained) chunks.push({ stream, text: retained });\n };\n\n stdout.write = interceptedWrite(\n stdout,\n 'stdout',\n originalStdoutWrite,\n capture,\n options.passthrough,\n );\n stderr.write = interceptedWrite(\n stderr,\n 'stderr',\n originalStderrWrite,\n capture,\n options.passthrough,\n );\n if (!options.passthrough) {\n for (const method of ['debug', 'info', 'log'] as const) {\n console[method] = (...args: unknown[]) => capture('stdout', `${format(...args)}\\n`);\n }\n for (const method of ['error', 'warn'] as const) {\n console[method] = (...args: unknown[]) => capture('stderr', `${format(...args)}\\n`);\n }\n }\n\n return {\n stop(): CapturedStepOutput {\n if (!stopped) {\n stdout.write = originalStdoutWrite;\n stderr.write = originalStderrWrite;\n for (const method of Object.keys(originalConsole) as ConsoleMethod[]) {\n console[method] = originalConsole[method];\n }\n stopped = true;\n }\n return {\n text: renderChunks(chunks),\n truncated: totalBytes > retainedBytes,\n totalBytes,\n };\n },\n };\n}\n\nfunction interceptedWrite(\n destination: Writable,\n stream: CapturedStream,\n original: Write,\n capture: (stream: CapturedStream, chunk: unknown) => void,\n passthrough = false,\n): Write {\n return function write(chunk: unknown, encodingOrCallback?: unknown, callback?: unknown): boolean {\n capture(stream, chunk);\n if (passthrough) {\n return original.call(\n destination,\n chunk as never,\n encodingOrCallback as never,\n callback as never,\n );\n }\n const done = typeof encodingOrCallback === 'function' ? encodingOrCallback : callback;\n if (typeof done === 'function') queueMicrotask(() => done());\n return true;\n } as Write;\n}\n\nfunction chunkToString(chunk: unknown): string {\n if (typeof chunk === 'string') return chunk;\n if (Buffer.isBuffer(chunk)) return chunk.toString('utf8');\n if (chunk instanceof Uint8Array) return Buffer.from(chunk).toString('utf8');\n return String(chunk);\n}\n\nfunction truncateUtf8(value: string, maxBytes: number): string {\n return Buffer.from(value)\n .subarray(0, maxBytes)\n .toString('utf8')\n .replace(/\\uFFFD$/u, '');\n}\n\nfunction renderChunks(chunks: readonly CapturedChunk[]): string {\n let rendered = '';\n let previous: CapturedStream | undefined;\n for (const chunk of chunks) {\n if (chunk.stream !== previous) {\n if (rendered && !rendered.endsWith('\\n')) rendered += '\\n';\n rendered += `[${chunk.stream}]\\n`;\n previous = chunk.stream;\n }\n rendered += chunk.text;\n }\n return rendered.trimEnd();\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,8 +1,10 @@
1
1
  import { World, IWorldOptions } from '@cucumber/cucumber';
2
2
  import { TestProfile, ExecutionContext, TableFixture, WorkspaceClientLike, PollOptions } from '@fabricorg/databricks-testkit';
3
3
  export { waitForPipelineUpdate } from '@fabricorg/databricks-testkit';
4
+ import { StepOutputCapture } from './output-capture.cjs';
5
+ export { CapturedStepOutput, StepOutputCaptureOptions, startStepOutputCapture } from './output-capture.cjs';
4
6
  export { RUN_STATES, RunState, parseDuration, parseTableIdentifier } from './parameter-types.cjs';
5
- export { EvidenceReport, EvidenceScenario, redactSecrets } from './evidence-formatter.cjs';
7
+ export { EvidenceReport, EvidenceScenario, FAILURE_EVIDENCE_MEDIA_TYPE, StepFailureEvidence, parseFailureEvidenceAttachment, redactSecrets } from './evidence-formatter.cjs';
6
8
 
7
9
  interface DatabricksWorldParameters {
8
10
  /** Default schema for the execution context; overridable per scenario via the catalog/schema step. */
@@ -33,6 +35,7 @@ declare class DatabricksWorld extends World<DatabricksWorldParameters> {
33
35
  catalogOverride: string | undefined;
34
36
  lastSql: string | undefined;
35
37
  lastStatementId: string | undefined;
38
+ stepOutputCapture: StepOutputCapture | undefined;
36
39
  lakebasePool: {
37
40
  query<T extends Record<string, unknown>>(sql: string): Promise<{
38
41
  rows: T[];
@@ -116,4 +119,4 @@ interface RunFeaturesResult {
116
119
  */
117
120
  declare function runFeatures(options: RunFeaturesOptions): Promise<RunFeaturesResult>;
118
121
 
119
- export { DatabricksWorld, type DatabricksWorldParameters, type JobRunResult, LIVE_ONLY_TAGS, type PipelineWaitOptions, type RunFeaturesOptions, type RunFeaturesResult, type RunJobOptions, coerceMatchRows, inferFixture, liveOnlyReason, resolveJobId, resolvePipelineId, runFeatures, runJobToTerminal, startPipelineUpdate };
122
+ export { DatabricksWorld, type DatabricksWorldParameters, type JobRunResult, LIVE_ONLY_TAGS, type PipelineWaitOptions, type RunFeaturesOptions, type RunFeaturesResult, type RunJobOptions, StepOutputCapture, coerceMatchRows, inferFixture, liveOnlyReason, resolveJobId, resolvePipelineId, runFeatures, runJobToTerminal, startPipelineUpdate };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  import { World, IWorldOptions } from '@cucumber/cucumber';
2
2
  import { TestProfile, ExecutionContext, TableFixture, WorkspaceClientLike, PollOptions } from '@fabricorg/databricks-testkit';
3
3
  export { waitForPipelineUpdate } from '@fabricorg/databricks-testkit';
4
+ import { StepOutputCapture } from './output-capture.js';
5
+ export { CapturedStepOutput, StepOutputCaptureOptions, startStepOutputCapture } from './output-capture.js';
4
6
  export { RUN_STATES, RunState, parseDuration, parseTableIdentifier } from './parameter-types.js';
5
- export { EvidenceReport, EvidenceScenario, redactSecrets } from './evidence-formatter.js';
7
+ export { EvidenceReport, EvidenceScenario, FAILURE_EVIDENCE_MEDIA_TYPE, StepFailureEvidence, parseFailureEvidenceAttachment, redactSecrets } from './evidence-formatter.js';
6
8
 
7
9
  interface DatabricksWorldParameters {
8
10
  /** Default schema for the execution context; overridable per scenario via the catalog/schema step. */
@@ -33,6 +35,7 @@ declare class DatabricksWorld extends World<DatabricksWorldParameters> {
33
35
  catalogOverride: string | undefined;
34
36
  lastSql: string | undefined;
35
37
  lastStatementId: string | undefined;
38
+ stepOutputCapture: StepOutputCapture | undefined;
36
39
  lakebasePool: {
37
40
  query<T extends Record<string, unknown>>(sql: string): Promise<{
38
41
  rows: T[];
@@ -116,4 +119,4 @@ interface RunFeaturesResult {
116
119
  */
117
120
  declare function runFeatures(options: RunFeaturesOptions): Promise<RunFeaturesResult>;
118
121
 
119
- export { DatabricksWorld, type DatabricksWorldParameters, type JobRunResult, LIVE_ONLY_TAGS, type PipelineWaitOptions, type RunFeaturesOptions, type RunFeaturesResult, type RunJobOptions, coerceMatchRows, inferFixture, liveOnlyReason, resolveJobId, resolvePipelineId, runFeatures, runJobToTerminal, startPipelineUpdate };
122
+ export { DatabricksWorld, type DatabricksWorldParameters, type JobRunResult, LIVE_ONLY_TAGS, type PipelineWaitOptions, type RunFeaturesOptions, type RunFeaturesResult, type RunJobOptions, StepOutputCapture, coerceMatchRows, inferFixture, liveOnlyReason, resolveJobId, resolvePipelineId, runFeatures, runJobToTerminal, startPipelineUpdate };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
- export { DatabricksWorld, LIVE_ONLY_TAGS, coerceMatchRows, inferFixture, liveOnlyReason, resolveJobId, resolvePipelineId, runJobToTerminal, startPipelineUpdate, waitForPipelineUpdate } from './chunk-EW5VNRZP.js';
2
- export { redactSecrets } from './chunk-LFEU3ZHD.js';
1
+ export { DatabricksWorld, LIVE_ONLY_TAGS, coerceMatchRows, inferFixture, liveOnlyReason, resolveJobId, resolvePipelineId, runJobToTerminal, startPipelineUpdate, waitForPipelineUpdate } from './chunk-FNTI2VUP.js';
2
+ export { FAILURE_EVIDENCE_MEDIA_TYPE, parseFailureEvidenceAttachment, redactSecrets } from './chunk-UQAKGVJS.js';
3
+ export { startStepOutputCapture } from './chunk-THB7O2G6.js';
3
4
  export { RUN_STATES, parseDuration, parseTableIdentifier } from './chunk-YNOLRERF.js';
4
5
  import { execFile } from 'child_process';
5
6
  import { createRequire } from 'module';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/run-features.ts"],"names":["require"],"mappings":";;;;;;;AA2BA,eAAsB,YAAY,OAAA,EAAyD;AACzF,EAAA,MAAMA,QAAAA,GAAU,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AAG7C,EAAA,MAAM,OAAA,GAAUA,QAAAA,CAAQ,OAAA,CAAQ,iCAAiC,CAAA;AACjE,EAAA,MAAM,GAAA,GAAMA,SAAQ,OAAO,CAAA;AAC3B,EAAA,MAAM,GAAA,GAAM,KAAK,OAAA,CAAQ,OAAO,GAAG,GAAA,CAAI,GAAA,CAAI,aAAa,CAAA,IAAK,iBAAiB,CAAA;AAC9E,EAAA,MAAM,MAAyB,EAAE,GAAG,QAAQ,GAAA,EAAK,GAAG,QAAQ,GAAA,EAAI;AAChE,EAAA,IAAI,OAAA,CAAQ,OAAO,IAAA,EAAM;AACvB,IAAA,MAAM,SAAA,GAAY,cAAA;AAClB,IAAA,GAAA,CAAI,YAAA,GAAe,IAAI,YAAA,GAAe,CAAA,EAAG,IAAI,YAAY,CAAA,CAAA,EAAI,SAAS,CAAA,CAAA,GAAK,SAAA;AAAA,EAC7E;AACA,EAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,OAAA,KAAY;AAC9B,IAAA,QAAA;AAAA,MACE,OAAA,CAAQ,QAAA;AAAA,MACR,CAAC,GAAA,EAAK,GAAI,OAAA,CAAQ,IAAA,IAAQ,EAAG,CAAA;AAAA,MAC7B,EAAE,GAAA,EAAK,OAAA,CAAQ,GAAA,EAAK,GAAA,EAAK,OAAA,EAAS,OAAA,CAAQ,SAAA,IAAa,IAAA,EAAS,SAAA,EAAW,EAAA,GAAK,IAAA,GAAO,IAAA,EAAK;AAAA,MAC5F,CAAC,KAAA,EAAO,MAAA,EAAQ,MAAA,KAAW;AACzB,QAAA,MAAM,QAAA,GACJ,KAAA,IAAS,OAAQ,KAAA,CAA6B,IAAA,KAAS,WACjD,KAAA,CAA4B,IAAA,IAAQ,CAAA,GACtC,KAAA,GACE,CAAA,GACA,CAAA;AACR,QAAA,OAAA,CAAQ,EAAE,OAAA,EAAS,QAAA,KAAa,GAAG,QAAA,EAAU,MAAA,EAAQ,GAAG,MAAM;AAAA,EAAK,MAAM,IAAI,CAAA;AAAA,MAC/E;AAAA,KACF;AAAA,EACF,CAAC,CAAA;AACH","file":"index.js","sourcesContent":["import { execFile } from 'node:child_process';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\n\nexport interface RunFeaturesOptions {\n /** Directory containing the cucumber config / features. */\n cwd: string;\n /** Extra CLI args, e.g. ['--tags', 'not @slow'] or ['features/foo.feature']. */\n args?: string[];\n /** Extra environment (merged over process.env). */\n env?: Record<string, string>;\n /** Load TypeScript support code via tsx (default true). */\n tsx?: boolean;\n timeoutMs?: number;\n}\n\nexport interface RunFeaturesResult {\n success: boolean;\n exitCode: number;\n output: string;\n}\n\n/**\n * Vitest bridge: run cucumber-js as a subprocess so feature suites can be\n * embedded in an existing vitest run (one CI entry point) without fighting\n * over cucumber's global step registry or vitest's module transforms.\n */\nexport async function runFeatures(options: RunFeaturesOptions): Promise<RunFeaturesResult> {\n const require = createRequire(import.meta.url);\n // The bin path is not in the package's exports map — resolve it relative\n // to package.json (which is exported).\n const pkgPath = require.resolve('@cucumber/cucumber/package.json');\n const pkg = require(pkgPath) as { bin: Record<string, string> };\n const bin = join(dirname(pkgPath), pkg.bin['cucumber-js'] ?? 'bin/cucumber.js');\n const env: NodeJS.ProcessEnv = { ...process.env, ...options.env };\n if (options.tsx ?? true) {\n const tsxImport = '--import tsx';\n env.NODE_OPTIONS = env.NODE_OPTIONS ? `${env.NODE_OPTIONS} ${tsxImport}` : tsxImport;\n }\n return new Promise((resolve) => {\n execFile(\n process.execPath,\n [bin, ...(options.args ?? [])],\n { cwd: options.cwd, env, timeout: options.timeoutMs ?? 120_000, maxBuffer: 16 * 1024 * 1024 },\n (error, stdout, stderr) => {\n const exitCode =\n error && typeof (error as { code?: unknown }).code === 'number'\n ? ((error as { code?: number }).code ?? 1)\n : error\n ? 1\n : 0;\n resolve({ success: exitCode === 0, exitCode, output: `${stdout}\\n${stderr}` });\n },\n );\n });\n}\n"]}
1
+ {"version":3,"sources":["../src/run-features.ts"],"names":["require"],"mappings":";;;;;;;;AA2BA,eAAsB,YAAY,OAAA,EAAyD;AACzF,EAAA,MAAMA,QAAAA,GAAU,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AAG7C,EAAA,MAAM,OAAA,GAAUA,QAAAA,CAAQ,OAAA,CAAQ,iCAAiC,CAAA;AACjE,EAAA,MAAM,GAAA,GAAMA,SAAQ,OAAO,CAAA;AAC3B,EAAA,MAAM,GAAA,GAAM,KAAK,OAAA,CAAQ,OAAO,GAAG,GAAA,CAAI,GAAA,CAAI,aAAa,CAAA,IAAK,iBAAiB,CAAA;AAC9E,EAAA,MAAM,MAAyB,EAAE,GAAG,QAAQ,GAAA,EAAK,GAAG,QAAQ,GAAA,EAAI;AAChE,EAAA,IAAI,OAAA,CAAQ,OAAO,IAAA,EAAM;AACvB,IAAA,MAAM,SAAA,GAAY,cAAA;AAClB,IAAA,GAAA,CAAI,YAAA,GAAe,IAAI,YAAA,GAAe,CAAA,EAAG,IAAI,YAAY,CAAA,CAAA,EAAI,SAAS,CAAA,CAAA,GAAK,SAAA;AAAA,EAC7E;AACA,EAAA,OAAO,IAAI,OAAA,CAAQ,CAAC,OAAA,KAAY;AAC9B,IAAA,QAAA;AAAA,MACE,OAAA,CAAQ,QAAA;AAAA,MACR,CAAC,GAAA,EAAK,GAAI,OAAA,CAAQ,IAAA,IAAQ,EAAG,CAAA;AAAA,MAC7B,EAAE,GAAA,EAAK,OAAA,CAAQ,GAAA,EAAK,GAAA,EAAK,OAAA,EAAS,OAAA,CAAQ,SAAA,IAAa,IAAA,EAAS,SAAA,EAAW,EAAA,GAAK,IAAA,GAAO,IAAA,EAAK;AAAA,MAC5F,CAAC,KAAA,EAAO,MAAA,EAAQ,MAAA,KAAW;AACzB,QAAA,MAAM,QAAA,GACJ,KAAA,IAAS,OAAQ,KAAA,CAA6B,IAAA,KAAS,WACjD,KAAA,CAA4B,IAAA,IAAQ,CAAA,GACtC,KAAA,GACE,CAAA,GACA,CAAA;AACR,QAAA,OAAA,CAAQ,EAAE,OAAA,EAAS,QAAA,KAAa,GAAG,QAAA,EAAU,MAAA,EAAQ,GAAG,MAAM;AAAA,EAAK,MAAM,IAAI,CAAA;AAAA,MAC/E;AAAA,KACF;AAAA,EACF,CAAC,CAAA;AACH","file":"index.js","sourcesContent":["import { execFile } from 'node:child_process';\nimport { createRequire } from 'node:module';\nimport { dirname, join } from 'node:path';\n\nexport interface RunFeaturesOptions {\n /** Directory containing the cucumber config / features. */\n cwd: string;\n /** Extra CLI args, e.g. ['--tags', 'not @slow'] or ['features/foo.feature']. */\n args?: string[];\n /** Extra environment (merged over process.env). */\n env?: Record<string, string>;\n /** Load TypeScript support code via tsx (default true). */\n tsx?: boolean;\n timeoutMs?: number;\n}\n\nexport interface RunFeaturesResult {\n success: boolean;\n exitCode: number;\n output: string;\n}\n\n/**\n * Vitest bridge: run cucumber-js as a subprocess so feature suites can be\n * embedded in an existing vitest run (one CI entry point) without fighting\n * over cucumber's global step registry or vitest's module transforms.\n */\nexport async function runFeatures(options: RunFeaturesOptions): Promise<RunFeaturesResult> {\n const require = createRequire(import.meta.url);\n // The bin path is not in the package's exports map — resolve it relative\n // to package.json (which is exported).\n const pkgPath = require.resolve('@cucumber/cucumber/package.json');\n const pkg = require(pkgPath) as { bin: Record<string, string> };\n const bin = join(dirname(pkgPath), pkg.bin['cucumber-js'] ?? 'bin/cucumber.js');\n const env: NodeJS.ProcessEnv = { ...process.env, ...options.env };\n if (options.tsx ?? true) {\n const tsxImport = '--import tsx';\n env.NODE_OPTIONS = env.NODE_OPTIONS ? `${env.NODE_OPTIONS} ${tsxImport}` : tsxImport;\n }\n return new Promise((resolve) => {\n execFile(\n process.execPath,\n [bin, ...(options.args ?? [])],\n { cwd: options.cwd, env, timeout: options.timeoutMs ?? 120_000, maxBuffer: 16 * 1024 * 1024 },\n (error, stdout, stderr) => {\n const exitCode =\n error && typeof (error as { code?: unknown }).code === 'number'\n ? ((error as { code?: number }).code ?? 1)\n : error\n ? 1\n : 0;\n resolve({ success: exitCode === 0, exitCode, output: `${stdout}\\n${stderr}` });\n },\n );\n });\n}\n"]}
@@ -0,0 +1,114 @@
1
+ 'use strict';
2
+
3
+ var util = require('util');
4
+
5
+ // src/output-capture.ts
6
+ var DEFAULT_MAX_BYTES = 32 * 1024;
7
+ function startStepOutputCapture(options = {}) {
8
+ const maxBytes = Math.max(0, options.maxBytes ?? DEFAULT_MAX_BYTES);
9
+ const stdout = process.stdout;
10
+ const stderr = process.stderr;
11
+ const originalStdoutWrite = stdout.write;
12
+ const originalStderrWrite = stderr.write;
13
+ const originalConsole = Object.fromEntries(
14
+ ["debug", "error", "info", "log", "warn"].map((method) => [method, console[method]])
15
+ );
16
+ const chunks = [];
17
+ let retainedBytes = 0;
18
+ let totalBytes = 0;
19
+ let stopped = false;
20
+ const capture = (stream, chunk) => {
21
+ const text = chunkToString(chunk);
22
+ const bytes = Buffer.byteLength(text);
23
+ totalBytes += bytes;
24
+ const remaining = maxBytes - retainedBytes;
25
+ if (remaining <= 0 || bytes === 0) return;
26
+ const retained = bytes <= remaining ? text : truncateUtf8(text, remaining);
27
+ retainedBytes += Buffer.byteLength(retained);
28
+ if (retained) chunks.push({ stream, text: retained });
29
+ };
30
+ stdout.write = interceptedWrite(
31
+ stdout,
32
+ "stdout",
33
+ originalStdoutWrite,
34
+ capture,
35
+ options.passthrough
36
+ );
37
+ stderr.write = interceptedWrite(
38
+ stderr,
39
+ "stderr",
40
+ originalStderrWrite,
41
+ capture,
42
+ options.passthrough
43
+ );
44
+ if (!options.passthrough) {
45
+ for (const method of ["debug", "info", "log"]) {
46
+ console[method] = (...args) => capture("stdout", `${util.format(...args)}
47
+ `);
48
+ }
49
+ for (const method of ["error", "warn"]) {
50
+ console[method] = (...args) => capture("stderr", `${util.format(...args)}
51
+ `);
52
+ }
53
+ }
54
+ return {
55
+ stop() {
56
+ if (!stopped) {
57
+ stdout.write = originalStdoutWrite;
58
+ stderr.write = originalStderrWrite;
59
+ for (const method of Object.keys(originalConsole)) {
60
+ console[method] = originalConsole[method];
61
+ }
62
+ stopped = true;
63
+ }
64
+ return {
65
+ text: renderChunks(chunks),
66
+ truncated: totalBytes > retainedBytes,
67
+ totalBytes
68
+ };
69
+ }
70
+ };
71
+ }
72
+ function interceptedWrite(destination, stream, original, capture, passthrough = false) {
73
+ return function write(chunk, encodingOrCallback, callback) {
74
+ capture(stream, chunk);
75
+ if (passthrough) {
76
+ return original.call(
77
+ destination,
78
+ chunk,
79
+ encodingOrCallback,
80
+ callback
81
+ );
82
+ }
83
+ const done = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
84
+ if (typeof done === "function") queueMicrotask(() => done());
85
+ return true;
86
+ };
87
+ }
88
+ function chunkToString(chunk) {
89
+ if (typeof chunk === "string") return chunk;
90
+ if (Buffer.isBuffer(chunk)) return chunk.toString("utf8");
91
+ if (chunk instanceof Uint8Array) return Buffer.from(chunk).toString("utf8");
92
+ return String(chunk);
93
+ }
94
+ function truncateUtf8(value, maxBytes) {
95
+ return Buffer.from(value).subarray(0, maxBytes).toString("utf8").replace(/\uFFFD$/u, "");
96
+ }
97
+ function renderChunks(chunks) {
98
+ let rendered = "";
99
+ let previous;
100
+ for (const chunk of chunks) {
101
+ if (chunk.stream !== previous) {
102
+ if (rendered && !rendered.endsWith("\n")) rendered += "\n";
103
+ rendered += `[${chunk.stream}]
104
+ `;
105
+ previous = chunk.stream;
106
+ }
107
+ rendered += chunk.text;
108
+ }
109
+ return rendered.trimEnd();
110
+ }
111
+
112
+ exports.startStepOutputCapture = startStepOutputCapture;
113
+ //# sourceMappingURL=output-capture.cjs.map
114
+ //# sourceMappingURL=output-capture.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/output-capture.ts"],"names":["format"],"mappings":";;;;;AAiCA,IAAM,oBAAoB,EAAA,GAAK,IAAA;AAQxB,SAAS,sBAAA,CAAuB,OAAA,GAAoC,EAAC,EAAsB;AAChG,EAAA,MAAM,WAAW,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,OAAA,CAAQ,YAAY,iBAAiB,CAAA;AAClE,EAAA,MAAM,SAAS,OAAA,CAAQ,MAAA;AACvB,EAAA,MAAM,SAAS,OAAA,CAAQ,MAAA;AACvB,EAAA,MAAM,sBAAsB,MAAA,CAAO,KAAA;AACnC,EAAA,MAAM,sBAAsB,MAAA,CAAO,KAAA;AACnC,EAAA,MAAM,kBAAkB,MAAA,CAAO,WAAA;AAAA,IAC5B,CAAC,OAAA,EAAS,OAAA,EAAS,MAAA,EAAQ,OAAO,MAAM,CAAA,CAAY,GAAA,CAAI,CAAC,WAAW,CAAC,MAAA,EAAQ,OAAA,CAAQ,MAAM,CAAC,CAAC;AAAA,GAChG;AACA,EAAA,MAAM,SAA0B,EAAC;AACjC,EAAA,IAAI,aAAA,GAAgB,CAA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Y,cAAA,CAAe,MAAM,MAAM,CAAA;AAC3D,IAAA,OAAO,IAAA;AAAA,EACT,CAAA;AACF;AAEA,SAAS,cAAc,KAAA,EAAwB;AAC7C,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,KAAA;AACtC,EAAA,IAAI,OAAO,QAAA,CAAS,KAAK,GAAG,OAAO,KAAA,CAAM,SAAS,MAAM,CAAA;AACxD,EAAA,IAAI,KAAA,YAAiB,YAAY,OAAO,MAAA,CAAO,KAAK,KAAK,CAAA,CAAE,SAAS,MAAM,CAAA;AAC1E,EAAA,OAAO,OAAO,KAAK,CAAA;AACrB;AAEA,SAAS,YAAA,CAAa,OAAe,QAAA,EAA0B;AAC7D,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,CACrB,QAAA,CAAS,CAAA,EAAG,QAAQ,CAAA,CACpB,QAAA,CAAS,MAAM,CAAA,CACf,OAAA,CAAQ,YAAY,EAAE,CAAA;AAC3B;AAEA,SAAS,aAAa,MAAA,EAA0C;AAC9D,EAAA,IAAI,QAAA,GAAW,EAAA;AACf,EAAA,IAAI,QAAA;AACJ,EAAA,KAAA,MAAW,SAAS,MAAA,EAAQ;AAC1B,IAAA,IAAI,KAAA,CAAM,WAAW,QAAA,EAAU;AAC7B,MAAA,IAAI,YAAY,CAAC,QAAA,CAAS,QAAA,CAAS,IAAI,GAAG,QAAA,IAAY,IAAA;AACtD,MAAA,QAAA,IAAY,CAAA,CAAA,EAAI,MAAM,MAAM,CAAA;AAAA,CAAA;AAC5B,MAAA,QAAA,GAAW,KAAA,CAAM,MAAA;AAAA,IACnB;AACA,IAAA,QAAA,IAAY,KAAA,CAAM,IAAA;AAAA,EACpB;AACA,EAAA,OAAO,SAAS,OAAA,EAAQ;AAC1B","file":"output-capture.cjs","sourcesContent":["import type { Writable } from 'node:stream';\nimport { format } from 'node:util';\n\nexport type CapturedStream = 'stdout' | 'stderr';\n\nexport interface CapturedStepOutput {\n /** Ordered stdout/stderr output with stream labels. */\n text: string;\n /** True when output exceeded the configured byte budget. */\n truncated: boolean;\n /** Total bytes emitted before truncation. */\n totalBytes: number;\n}\n\nexport interface StepOutputCapture {\n stop(): CapturedStepOutput;\n}\n\nexport interface StepOutputCaptureOptions {\n /** Maximum UTF-8 bytes retained for one step. Defaults to 32 KiB. */\n maxBytes?: number;\n /** Forward output while capturing. Defaults to false, matching Behave capture semantics. */\n passthrough?: boolean;\n}\n\ninterface CapturedChunk {\n stream: CapturedStream;\n text: string;\n}\n\ntype Write = Writable['write'];\ntype ConsoleMethod = 'debug' | 'error' | 'info' | 'log' | 'warn';\n\nconst DEFAULT_MAX_BYTES = 32 * 1024;\n\n/**\n * Capture process stdout/stderr until stop() is called. Console output and\n * Pino's standard destination both flow through these streams. Child\n * processes that inherit the OS file descriptors directly are intentionally\n * outside this in-process capture boundary.\n */\nexport function startStepOutputCapture(options: StepOutputCaptureOptions = {}): StepOutputCapture {\n const maxBytes = Math.max(0, options.maxBytes ?? DEFAULT_MAX_BYTES);\n const stdout = process.stdout;\n const stderr = process.stderr;\n const originalStdoutWrite = stdout.write;\n const originalStderrWrite = stderr.write;\n const originalConsole = Object.fromEntries(\n (['debug', 'error', 'info', 'log', 'warn'] as const).map((method) => [method, console[method]]),\n ) as Record<ConsoleMethod, typeof console.log>;\n const chunks: CapturedChunk[] = [];\n let retainedBytes = 0;\n let totalBytes = 0;\n let stopped = false;\n\n const capture = (stream: CapturedStream, chunk: unknown): void => {\n const text = chunkToString(chunk);\n const bytes = Buffer.byteLength(text);\n totalBytes += bytes;\n const remaining = maxBytes - retainedBytes;\n if (remaining <= 0 || bytes === 0) return;\n const retained = bytes <= remaining ? text : truncateUtf8(text, remaining);\n retainedBytes += Buffer.byteLength(retained);\n if (retained) chunks.push({ stream, text: retained });\n };\n\n stdout.write = interceptedWrite(\n stdout,\n 'stdout',\n originalStdoutWrite,\n capture,\n options.passthrough,\n );\n stderr.write = interceptedWrite(\n stderr,\n 'stderr',\n originalStderrWrite,\n capture,\n options.passthrough,\n );\n if (!options.passthrough) {\n for (const method of ['debug', 'info', 'log'] as const) {\n console[method] = (...args: unknown[]) => capture('stdout', `${format(...args)}\\n`);\n }\n for (const method of ['error', 'warn'] as const) {\n console[method] = (...args: unknown[]) => capture('stderr', `${format(...args)}\\n`);\n }\n }\n\n return {\n stop(): CapturedStepOutput {\n if (!stopped) {\n stdout.write = originalStdoutWrite;\n stderr.write = originalStderrWrite;\n for (const method of Object.keys(originalConsole) as ConsoleMethod[]) {\n console[method] = originalConsole[method];\n }\n stopped = true;\n }\n return {\n text: renderChunks(chunks),\n truncated: totalBytes > retainedBytes,\n totalBytes,\n };\n },\n };\n}\n\nfunction interceptedWrite(\n destination: Writable,\n stream: CapturedStream,\n original: Write,\n capture: (stream: CapturedStream, chunk: unknown) => void,\n passthrough = false,\n): Write {\n return function write(chunk: unknown, encodingOrCallback?: unknown, callback?: unknown): boolean {\n capture(stream, chunk);\n if (passthrough) {\n return original.call(\n destination,\n chunk as never,\n encodingOrCallback as never,\n callback as never,\n );\n }\n const done = typeof encodingOrCallback === 'function' ? encodingOrCallback : callback;\n if (typeof done === 'function') queueMicrotask(() => done());\n return true;\n } as Write;\n}\n\nfunction chunkToString(chunk: unknown): string {\n if (typeof chunk === 'string') return chunk;\n if (Buffer.isBuffer(chunk)) return chunk.toString('utf8');\n if (chunk instanceof Uint8Array) return Buffer.from(chunk).toString('utf8');\n return String(chunk);\n}\n\nfunction truncateUtf8(value: string, maxBytes: number): string {\n return Buffer.from(value)\n .subarray(0, maxBytes)\n .toString('utf8')\n .replace(/\\uFFFD$/u, '');\n}\n\nfunction renderChunks(chunks: readonly CapturedChunk[]): string {\n let rendered = '';\n let previous: CapturedStream | undefined;\n for (const chunk of chunks) {\n if (chunk.stream !== previous) {\n if (rendered && !rendered.endsWith('\\n')) rendered += '\\n';\n rendered += `[${chunk.stream}]\\n`;\n previous = chunk.stream;\n }\n rendered += chunk.text;\n }\n return rendered.trimEnd();\n}\n"]}
@@ -0,0 +1,27 @@
1
+ type CapturedStream = 'stdout' | 'stderr';
2
+ interface CapturedStepOutput {
3
+ /** Ordered stdout/stderr output with stream labels. */
4
+ text: string;
5
+ /** True when output exceeded the configured byte budget. */
6
+ truncated: boolean;
7
+ /** Total bytes emitted before truncation. */
8
+ totalBytes: number;
9
+ }
10
+ interface StepOutputCapture {
11
+ stop(): CapturedStepOutput;
12
+ }
13
+ interface StepOutputCaptureOptions {
14
+ /** Maximum UTF-8 bytes retained for one step. Defaults to 32 KiB. */
15
+ maxBytes?: number;
16
+ /** Forward output while capturing. Defaults to false, matching Behave capture semantics. */
17
+ passthrough?: boolean;
18
+ }
19
+ /**
20
+ * Capture process stdout/stderr until stop() is called. Console output and
21
+ * Pino's standard destination both flow through these streams. Child
22
+ * processes that inherit the OS file descriptors directly are intentionally
23
+ * outside this in-process capture boundary.
24
+ */
25
+ declare function startStepOutputCapture(options?: StepOutputCaptureOptions): StepOutputCapture;
26
+
27
+ export { type CapturedStepOutput, type CapturedStream, type StepOutputCapture, type StepOutputCaptureOptions, startStepOutputCapture };
@@ -0,0 +1,27 @@
1
+ type CapturedStream = 'stdout' | 'stderr';
2
+ interface CapturedStepOutput {
3
+ /** Ordered stdout/stderr output with stream labels. */
4
+ text: string;
5
+ /** True when output exceeded the configured byte budget. */
6
+ truncated: boolean;
7
+ /** Total bytes emitted before truncation. */
8
+ totalBytes: number;
9
+ }
10
+ interface StepOutputCapture {
11
+ stop(): CapturedStepOutput;
12
+ }
13
+ interface StepOutputCaptureOptions {
14
+ /** Maximum UTF-8 bytes retained for one step. Defaults to 32 KiB. */
15
+ maxBytes?: number;
16
+ /** Forward output while capturing. Defaults to false, matching Behave capture semantics. */
17
+ passthrough?: boolean;
18
+ }
19
+ /**
20
+ * Capture process stdout/stderr until stop() is called. Console output and
21
+ * Pino's standard destination both flow through these streams. Child
22
+ * processes that inherit the OS file descriptors directly are intentionally
23
+ * outside this in-process capture boundary.
24
+ */
25
+ declare function startStepOutputCapture(options?: StepOutputCaptureOptions): StepOutputCapture;
26
+
27
+ export { type CapturedStepOutput, type CapturedStream, type StepOutputCapture, type StepOutputCaptureOptions, startStepOutputCapture };
@@ -0,0 +1,3 @@
1
+ export { startStepOutputCapture } from './chunk-THB7O2G6.js';
2
+ //# sourceMappingURL=output-capture.js.map
3
+ //# sourceMappingURL=output-capture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"output-capture.js"}