UNPKG

@dhlab/e2e-autogen

Version:

Google 스프레드시트 기반 시나리오를 Playwright 테스트 스텁 코드로 자동 생성하고, 테스트 실행 결과를 다시 시트에 업데이트하는 CLI 도구

111 lines (101 loc) 5.36 kB
'use strict'; var _CliApplication_instances, _CliApplication_command, _CliApplication_showUsage, _CliApplication_showVersion, _CliApplication_generateStub, _CliApplication_logResults; Object.defineProperty(exports, "__esModule", { value: true }); exports.CliApplication = void 0; const tslib_1 = require("tslib"); const ts_pattern_1 = require("ts-pattern"); const google_spreadsheets_1 = require("../google-spreadsheets"); const test_coverage_1 = require("../test-coverage"); const test_registry_1 = require("../test-registry"); const test_scribe_1 = require("../test-scribe"); const command_1 = require("./command"); class CliApplication { constructor(args, config) { _CliApplication_instances.add(this); _CliApplication_command.set(this, void 0); tslib_1.__classPrivateFieldSet(this, _CliApplication_command, new command_1.Command(args, config), "f"); } async run() { try { (0, ts_pattern_1.match)(tslib_1.__classPrivateFieldGet(this, _CliApplication_command, "f")) .with({ type: "FLAG", flag: "HELP" }, () => { tslib_1.__classPrivateFieldGet(this, _CliApplication_instances, "m", _CliApplication_showUsage).call(this); process.exit(0); }) .with({ type: "FLAG", flag: "VERSION" }, () => { tslib_1.__classPrivateFieldGet(this, _CliApplication_instances, "m", _CliApplication_showVersion).call(this); process.exit(0); }) .with({ type: "SUB_COMMAND", subCommand: "GENERATE" }, async () => { await tslib_1.__classPrivateFieldGet(this, _CliApplication_instances, "m", _CliApplication_generateStub).call(this); }) .with({ type: "SUB_COMMAND", subCommand: "UPDATE" }, async () => { await tslib_1.__classPrivateFieldGet(this, _CliApplication_instances, "m", _CliApplication_logResults).call(this); }) .exhaustive(); } catch (error) { console.error(error); process.exit(1); } } } exports.CliApplication = CliApplication; _CliApplication_command = new WeakMap(), _CliApplication_instances = new WeakSet(), _CliApplication_showUsage = function _CliApplication_showUsage() { console.log(` ┌─────────────────────────────────────────────────────────────────┐ │ E2E AutoGen │ │ Google Sheets 기반 E2E 테스트 자동화 │ └─────────────────────────────────────────────────────────────────┘ 📋 사용법: e2e-autogen [명령어] [옵션] 🚀 명령어: generate Google Sheets에서 스텁 코드 생성 update 테스트 결과를 Google Sheets에 업데이트 🔧 옵션: -h, --help 도움말 표시 -v, --version 버전 정보 표시 📋 설정 파일: 프로젝트 루트에 'e2e-autogen.config.ts' 파일이 필요합니다. 예시 설정: export default { sheetsUrl: "https://docs.google.com/spreadsheets/d/...", framework: "playwright", // 또는 "detox" stubOutputFolder: "./tests/e2e", jsonReporterFile: "./test-results.json", credentialsFile: "./credentials.json", googleSheetColumns: { scenarioId: "A", scenarioDescription: "B", uiPath: "C", when: "D", then: "E", testId: "F", tag: "G", comment: "H" } }; 💡 사용 예시: # 스텁 코드 생성 e2e-autogen generate # 테스트 결과 업데이트 e2e-autogen update 📚 자세한 문서: https://github.com/dhlab-org/e2e-autogen `); }, _CliApplication_showVersion = function _CliApplication_showVersion() { // TODO: rollup 수정 후 버전 표시 추가 console.log(`e2e-autogen vtest`); }, _CliApplication_generateStub = async function _CliApplication_generateStub() { const { sheetsUrl, credentialsFile, stubOutputFolder, framework, googleSheetColumns, } = tslib_1.__classPrivateFieldGet(this, _CliApplication_command, "f").optionsOf("GENERATE"); const googleSpreadsheets = await (0, google_spreadsheets_1.authorizedGoogleSpreadsheets)(sheetsUrl, credentialsFile, googleSheetColumns); const testScribe = new test_scribe_1.TestScribe(googleSpreadsheets, stubOutputFolder); await testScribe.generateStubFor(framework); }, _CliApplication_logResults = async function _CliApplication_logResults() { const { sheetsUrl, jsonReporterFile, credentialsFile, googleSheetColumns } = tslib_1.__classPrivateFieldGet(this, _CliApplication_command, "f").optionsOf("UPDATE"); const googleSpreadsheets = await (0, google_spreadsheets_1.authorizedGoogleSpreadsheets)(sheetsUrl, credentialsFile, googleSheetColumns); const testRegistry = new test_registry_1.TestRegistry(jsonReporterFile, googleSpreadsheets); const resultsPerSuite = await testRegistry.resultsPerSuite(); await testRegistry.logResults(resultsPerSuite); const testCoverage = new test_coverage_1.TestCoverage(resultsPerSuite); await testCoverage.update(googleSpreadsheets); };