UNPKG

playwright-json-runner

Version:

Extends Playwright to run tests using JSON-based test definitions.

1 lines 3.71 kB
{"version":3,"sources":["../node_modules/@playwright/test/index.mjs","../src/runner-playwright.ts"],"names":["default","test_star","jsonFiles","_a"],"mappings":";;;;;;;;AAAA,IAAA,YAAA,GAAA,EAAA;AAAA,QAAA,CAAA,YAAA,EAAA;AAAA,EAAAA,OAAAA,EAAAA,MAAAA;AAAA,CAAA,CAAA;AAgBA,UAAA,CAAA,YAAA,EAAAC,QAAA,CAAA;ACTA,SAAS,aAAgB,GAAA;AACvB,EAAA,MAAM,SAAS,gBAAiB,EAAA;AAChC,EAAA,MAAM,cAAc,MAAO,CAAA,WAAA;AAC3B,EAAA,MAAM,kBAAkB,MAAO,CAAA,aAAA;AAE/B,EAAA,MAAM,gBAAmB,GAAA,CAAA,GAAA,EAAM,WAAW,CAAA,CAAA,EAAI,eAAe,CAAA,CAAA;AAC7D,EAAQ,OAAA,CAAA,GAAA,CAAI,qCAAqC,gBAAgB,CAAA;AACjE,EAAMC,MAAAA,UAAAA,GAAY,SAAS,gBAAgB,CAAA;AAC3C,EAAA,OAAA,CAAQ,IAAI,QAAUA,EAAAA,UAAAA,IAAA,IAAAA,GAAAA,MAAAA,GAAAA,UAAAA,CAAW,QAAQ,SAAS,CAAA;AAElD,EAAOA,OAAAA,UAAAA;AACT;AAEA,IAAM,YAAY,aAAc,EAAA;AApBhC,IAAA,EAAA;AAsBA,KAAA,MAAW,gBAAgB,SAAW,EAAA;AACpC,EAAA,MAAM,UAAmB,IAAK,CAAA,KAAA,CAAM,YAAa,CAAA,YAAA,EAAc,OAAO,CAAC,CAAA;AACvE,EAAA,MAAM,SAAS,gBAAiB,EAAA;AAEhC,EAAW,KAAA,MAAA,QAAA,IAAY,QAAQ,SAAW,EAAA;AACxC,IAAK,IAAA,YAAA,CAAA,IAAA,EAAA,CAAA,EAAA,GAAA,QAAA,CAAS,UAAT,IAAkB,GAAA,EAAA,GAAA,QAAA,CAAS,MAAM,OAAO,EAAE,MAAW,KAAA;AA3B9D,MAAA,IAAAC,GAAA,EAAA,EAAA;AA4BM,MAAM,MAAA,IAAA,CAAK,IAAK,CAAA,OAAA,CAAQ,IAAI,CAAA;AAC5B,MAAQ,OAAA,CAAA,GAAA,CAAI,kCAA0BA,GAAA,GAAA,QAAA,CAAS,UAAT,IAAAA,GAAAA,GAAAA,GAAkB,QAAS,CAAA,IAAI,CAAE,CAAA,CAAA;AAEvE,MAAW,KAAA,MAAA,IAAA,IAAQ,SAAS,KAAO,EAAA;AACjC,QAAA,OAAA,CAAQ,IAAI,CAAc,kBAAA,EAAA,CAAA,EAAA,GAAA,IAAA,CAAK,UAAL,IAAc,GAAA,EAAA,GAAA,IAAA,CAAK,WAAW,CAAE,CAAA,CAAA;AAE1D,QAAW,KAAA,MAAA,MAAA,IAAU,KAAK,OAAS,EAAA;AACjC,UAAM,MAAA,aAAA,CAAc,MAAQ,EAAA,IAAA,EAAM,MAAM,CAAA;AAAA;AAC1C;AACF,KACD,CAAA;AAAA;AAEL","file":"runner-playwright.mjs","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport * from 'playwright/test';\nexport { default } from 'playwright/test';\n","import { getConfiguration } from \".\";\nimport { test } from '@playwright/test'\nimport { readFileSync } from \"fs\";\nimport { globSync } from \"glob\";\nimport { TestRun } from \".\";\nimport { executeAction } from \".\";\n\nfunction loadTestFiles() {\n const config = getConfiguration();\n const jsonTestDir = config.jsonTestDir;\n const jsonTestPattern = config.jsonTestMatch;\n\n const finalGlobPattern = `**/${jsonTestDir}/${jsonTestPattern}`;\n console.log(\"Glob pattern to find test files: \", finalGlobPattern);\n const jsonFiles = globSync(finalGlobPattern);\n console.log(\"Found \", jsonFiles?.length, \" Files.\");\n\n return jsonFiles;\n}\n\nconst jsonFiles = loadTestFiles();;\n\nfor (const testFilePath of jsonFiles) {\n const testRun: TestRun = JSON.parse(readFileSync(testFilePath, 'utf-8'));\n const config = getConfiguration();\n\n for (const scenario of testRun.scenarios) {\n test(scenario.label ?? scenario.name, async ({ page }) => {\n await page.goto(testRun.host);\n console.log(`📌 Executing scenario: ${scenario.label ?? scenario.name}`);\n\n for (const step of scenario.steps) {\n console.log(` 🛠 Step: ${step.label ?? step.description}`);\n\n for (const action of step.actions) {\n await executeAction(config, page, action);\n }\n }\n })\n }\n}\n"]}