UNPKG

cypress-testbench-reporter

Version:
67 lines 2.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const mocha_1 = require("mocha"); const testbench_1 = require("./testbench"); const testbench_interface_1 = require("./testbench.interface"); class CypressTestBenchReporter extends mocha_1.reporters.Spec { constructor(runner, options) { super(runner); this.results = []; let reporterOptions = options.reporterOptions; this.testBenchAutomation = new testbench_1.TestBenchAutomation(reporterOptions); this.validate(reporterOptions, 'domain'); this.validate(reporterOptions, 'tenantName'); this.validate(reporterOptions, 'username'); this.validate(reporterOptions, 'password'); this.validate(reporterOptions, 'productId'); runner.on('start', () => { this.testBenchAutomation.login(); }); runner.on('pass', test => { const testCase = this.testCase(test); if (testCase == undefined) { console.log(`Could not extract external Id from passed test ${test.title}`); } else { this.testBenchAutomation.runAutomatedTest(testCase, testbench_interface_1.Status.Passed); } }); runner.on('fail', test => { const testCase = this.testCase(test); if (testCase == undefined) { console.log(`Could not extract external Id from failed test ${test.title}`); } else { this.testBenchAutomation.runAutomatedTest(testCase, testbench_interface_1.Status.Failed); } }); runner.on('end', () => { //this.testBenchAutomation.logout(); }); } testCase(test) { const matches = /^\[(.*)\]/gm.exec(test.title); if (matches == undefined || matches[1] == undefined || matches[1].trim() == "") return undefined; const externalId = matches[1]; const description = { text: test.fullTitle() }; return { externalId: externalId, name: test.title, description: description, testSteps: undefined, overwrite: false, markForReview: true }; } validate(options, name) { if (options == null) { throw new Error('Missing reporterOptions in cypress.json'); } if (options[name] == null) { throw new Error(`Missing ${name} value. Please update reporterOptions in cypress.json`); } } } exports.CypressTestBenchReporter = CypressTestBenchReporter; //# sourceMappingURL=cypress-testbench-reporter.js.map