UNPKG

k6-cucumber-steps

Version:

Cucumber step definitions for running k6 performance tests.

26 lines (21 loc) 823 B
import path from "path"; import fs from "fs"; /** * Resolves the full path to a payload file based on a root directory (e.g., from config) * and filename. Throws a clear error if file does not exist. * * @param {string} fileName - The file name (e.g., login.json) * @param {string} payloadDir - Directory path for payloads (absolute or relative) * @returns {string} - Full path to the resolved file */ export default function resolvePayloadPath(fileName, payloadDir = "payloads") { const projectRoot = path.resolve(process.cwd()); const baseDir = path.isAbsolute(payloadDir) ? payloadDir : path.join(projectRoot, payloadDir); const fullPath = path.join(baseDir, fileName); if (!fs.existsSync(fullPath)) { throw new Error(`❌ Payload file not found: "${fullPath}"`); } return fullPath; }