UNPKG

playwright-json-runner

Version:

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

44 lines (43 loc) 1.77 kB
import { getConfiguration, executeAction } from './chunk-CLGBQMKP.mjs'; import { __export, __reExport } from './chunk-JCIGD4K4.mjs'; import * as default2 from 'playwright/test'; import default2__default from 'playwright/test'; import { readFileSync } from 'fs'; import { globSync } from 'glob'; // node_modules/@playwright/test/index.mjs var test_exports = {}; __export(test_exports, { default: () => default2__default }); __reExport(test_exports, default2); function loadTestFiles() { const config = getConfiguration(); const jsonTestDir = config.jsonTestDir; const jsonTestPattern = config.jsonTestMatch; const finalGlobPattern = `**/${jsonTestDir}/${jsonTestPattern}`; console.log("Glob pattern to find test files: ", finalGlobPattern); const jsonFiles2 = globSync(finalGlobPattern); console.log("Found ", jsonFiles2 == null ? void 0 : jsonFiles2.length, " Files."); return jsonFiles2; } var jsonFiles = loadTestFiles(); var _a; for (const testFilePath of jsonFiles) { const testRun = JSON.parse(readFileSync(testFilePath, "utf-8")); const config = getConfiguration(); for (const scenario of testRun.scenarios) { (0, test_exports.test)((_a = scenario.label) != null ? _a : scenario.name, async ({ page }) => { var _a2, _b; await page.goto(testRun.host); console.log(`\u{1F4CC} Executing scenario: ${(_a2 = scenario.label) != null ? _a2 : scenario.name}`); for (const step of scenario.steps) { console.log(` \u{1F6E0} Step: ${(_b = step.label) != null ? _b : step.description}`); for (const action of step.actions) { await executeAction(config, page, action); } } }); } } //# sourceMappingURL=runner-playwright.mjs.map //# sourceMappingURL=runner-playwright.mjs.map