UNPKG

playwright-sit-converter

Version:

Convert Playwright test scripts to SIT (System Integration Testing) documentation

40 lines (39 loc) 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.main = main; const fs_1 = require("fs"); const builder_1 = require("./builder"); const test_1 = require("@playwright/test"); async function generatePlaywrightScript(url) { try { console.log(`Generating Playwright script for ${url}...`); const browser = await test_1.chromium.launch({ headless: false }); const context = await browser.newContext({ /* pass any options */}); await context.route('**/*', route => route.continue()); const page = await context.newPage(); await page.pause(); console.log('Playwright script generated successfully.'); } catch (error) { console.error('Error generating Playwright script:', error); process.exit(1); } } async function main(url = 'https://www.google.com') { const apiKey = process.env.GEMINI_API_KEY; if (!apiKey) { console.error("Please set the GEMINI_API_KEY environment variable"); process.exit(1); } // await generatePlaywrightScript(url); const geminiAI = new builder_1.BobTheBuilder(apiKey); try { const playwrightScript = await fs_1.promises.readFile('input.test', 'utf-8'); const response = await geminiAI.generateResponse(playwrightScript); await fs_1.promises.writeFile('output.csv', response); console.log('Output written to output.csv'); } catch (error) { console.error('Error processing the script:', error); } }