UNPKG

jest-allure2-adapter

Version:
74 lines (70 loc) 2.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CustomReporterCirc = void 0; const allure_reporter_1 = require("./allure-reporter"); // export const initCircus = (allureapi: AllureReporterApi) =>{ class CustomReporterCirc { constructor(globalOptions, options) { this.globalOptions = globalOptions; this.options = options; // Constructor logic, if any console.log('CustomReporter initialized with options:', options); this.allure = new allure_reporter_1.AllureReporter(options); (global.reporter = this.allure); } /*suiteStarted(suite?: jasmine_.CustomReporterResult) { if (suite) { this.allure.startGroup(suite.description); } else { // case for tests without suite this.allure.startGroup( relative(process.cwd(), (expect as any).getState().testPath), ); } } suiteDone() { this.allure.endGroup(); } specStarted(spec: jasmine_.CustomReporterResult) { this.allure.startTest(spec); } specDone(spec: jasmine_.CustomReporterResult) { this.allure.endTest(spec); } */ onRunStart(_aggregatedResults, _options) { // Called when the test run starts console.log('Test run started'); } onTestStart(test) { console.log('STARTED:' + JSON.stringify(test, null, ' ')); this.allure.startTest({ description: '', // failedExpectations?: any[]; fullName: test.path, testPath: test.path, id: test.context.config.id //passedExpectations?: any[]; //pendingReason?: string; //status?: string; }); } onTestResult(_test, _testResult, _aggregatedResults) { // Called for each test result // You can access the individual test and its result here console.log(`TEST RES:${_test.path}`); } onRunComplete(testContexts, results) { console.log(`Test run completed`); //JSON.stringify(results) } // Optionally, reporters can force Jest to exit with non zero code by returning // an `Error` from `getLastError()` method. getLastError() { //if (this._shouldFail) { return new Error('Custom error reported!'); //} } } exports.CustomReporterCirc = CustomReporterCirc; // return CustomReporterCirc; // Return the constructor itself //}