playwright-json-runner
Version:
Extends Playwright to run tests using JSON-based test definitions.
1 lines • 2.27 kB
Source Map (JSON)
{"version":3,"sources":["../../src/scripts/cli.ts"],"names":[],"mappings":";;;;;AAcA,SAAS,UAAa,GAAA;AACpB,EAAA,OAAO,gBAAgB,aAAe,EAAA;AAAA,IACpC,IAAM,EAAA;AAAA,GACP,CAAA;AACH;AAAA,CAGC,eAAe,IAAO,GAAA;AACrB,EAAA,MAAM,KAAK,OAAS,EAAA,UAAU,IAAI,OAAQ,CAAA,IAAA;AAE1C,EAAA,IAAI,YAAY,kBAAoB,EAAA;AAElC,IAAA,MAAM,WAAW,UAAc,IAAA,oCAAA;AAC/B,IAAI,IAAA;AAEF,MAAM,MAAA,UAAA,GAAa,MAAM,UAAW,EAAA;AAEpC,MAAG,EAAA,CAAA,aAAA,CAAc,QAAU,EAAA,OAAO,UAAe,KAAA,QAAA,GAAW,UAAa,GAAA,IAAA,CAAK,SAAU,CAAA,UAAA,EAAY,IAAM,EAAA,CAAC,CAAC,CAAA;AAC5G,MAAQ,OAAA,CAAA,GAAA,CAAI,CAAoB,iBAAA,EAAA,QAAQ,CAAE,CAAA,CAAA;AAAA,aACnC,KAAO,EAAA;AACd,MAAQ,OAAA,CAAA,KAAA,CAAM,8BAA8B,KAAK,CAAA;AACjD,MAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAChB,GACK,MAAA;AACL,IAAQ,OAAA,CAAA,GAAA;AAAA,MACN,CAAA;AAAA;;AAAA;AAAA,qDAAA;AAAA,KACF;AACA,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA;AAElB,CAAG,GAAA","file":"cli.mjs","sourcesContent":["#!/usr/bin/env node\n\n/**\n * scripts/cli.ts\n *\n * This is the main entry for CLI.\n * It expects usage: \n * playwright-json-runner dump-json-schema <outputFile>\n */\n\nimport * as fs from \"fs\";\nimport { testRunSchema } from \"../schemas/test-run\";\nimport zodToJsonSchema from \"zod-to-json-schema\";\n\nfunction dumpSchema() {\n return zodToJsonSchema(testRunSchema, {\n name: \"TestRun\",\n });\n}\n\n\n(async function main() {\n const [, , command, outputFile] = process.argv;\n\n if (command === \"dump-json-schema\") {\n // If user didn't specify a filename, default to \"schema.json\"\n const fileName = outputFile || \"playwright-json-runner-schema.json\";\n try {\n // Suppose dumpSchema returns a JSON object or string\n const schemaJson = await dumpSchema(); \n // If it’s an object, stringify; if it’s a string, just write directly\n fs.writeFileSync(fileName, typeof schemaJson === \"string\" ? schemaJson : JSON.stringify(schemaJson, null, 2));\n console.log(`Schema dumped to ${fileName}`);\n } catch (error) {\n console.error(\"Error dumping JSON Schema:\", error);\n process.exit(1);\n }\n } else {\n console.log(\n `Usage:\\n playwright-json-runner dump-json-schema <outputFile>\\n\\nExample:\\n playwright-json-runner dump-json-schema schema.json`\n );\n process.exit(0);\n }\n})();\n"]}