UNPKG

@teambit/tester

Version:
54 lines (52 loc) 1.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.testsResultsToJUnitFormat = testsResultsToJUnitFormat; function _junitReportBuilder() { const data = _interopRequireDefault(require("junit-report-builder")); _junitReportBuilder = function () { return data; }; return data; } function _stripAnsi() { const data = _interopRequireDefault(require("strip-ansi")); _stripAnsi = function () { return data; }; return data; } function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } function testsResultsToJUnitFormat(components) { const builder = _junitReportBuilder().default.newBuilder(); components.forEach(compResult => { const suite = builder.testSuite().name(compResult.componentId.toString()); if (compResult.results?.start) { suite.timestamp(new Date(compResult.results?.start).toISOString()); } compResult.results?.testFiles.forEach(testFile => { if (testFile.error) { const testCase = suite.testCase().className(testFile.file).name(testFile.file); testCase.error((0, _stripAnsi().default)(testFile.error.message)); } testFile.tests.forEach(test => { const testCase = suite.testCase().className(testFile.file).name(test.name); if (test.error) { testCase.error((0, _stripAnsi().default)(test.error)); } if (test.failure) { testCase.failure((0, _stripAnsi().default)(test.failure)); } if (test.status === 'skipped' || test.status === 'pending') { testCase.skipped(); } if (test.duration) { testCase.time(test.duration / 1000); } }); }); }); return builder.build(); } //# sourceMappingURL=junit-generator.js.map