Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

allure-jasmine

Package Overview
Dependencies
Maintainers
0
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

allure-jasmine - npm Package Compare versions

Comparing version 3.0.0-beta.6 to 3.0.0-beta.7

dist/cjs/testplan.js

297

dist/cjs/index.js

@@ -13,2 +13,3 @@ "use strict";

var _runtime = require("allure-js-commons/sdk/runtime");
var _testplan = require("./testplan.js");
var _utils = require("./utils.js");

@@ -22,5 +23,10 @@ var _excluded = ["resultsDir"];

function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }

@@ -44,8 +50,146 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }

} = _nodeProcess.env;
var _startScope = /*#__PURE__*/new WeakMap();
var _startFixture = /*#__PURE__*/new WeakMap();
var _stopFixture = /*#__PURE__*/new WeakMap();
var _stopScope = /*#__PURE__*/new WeakMap();
var _enableAllureFeatures = /*#__PURE__*/new WeakMap();
var _AllureJasmineReporter_brand = /*#__PURE__*/new WeakSet();
var _injectFixtureSupportToHookFn = /*#__PURE__*/new WeakMap();
var _wrapSyncOrPromiseBasedHookInAllureFixture = /*#__PURE__*/new WeakMap();
var _wrapCallbackBasedHookInAllureFixture = /*#__PURE__*/new WeakMap();
var _callHookAndStopFixtureOnSyncError = /*#__PURE__*/new WeakMap();
var _stopFixtureWhenPromiseIsDone = /*#__PURE__*/new WeakMap();
var _injectStopFixtureToHookCallback = /*#__PURE__*/new WeakMap();
var _resolveStatusWithDetails = /*#__PURE__*/new WeakMap();
class AllureJasmineReporter {
constructor(config) {
var _this2 = this;
_classPrivateMethodInitSpec(this, _AllureJasmineReporter_brand);
_defineProperty(this, "allureRuntime", void 0);
_defineProperty(this, "currentAllureTestUuid", void 0);
_defineProperty(this, "currentAllureFixtureUuid", void 0);
_defineProperty(this, "jasmineSuitesStack", []);
_defineProperty(this, "scopesStack", []);
_classPrivateFieldInitSpec(this, _startScope, () => {
var scopeUuid = this.allureRuntime.startScope();
this.scopesStack.push(scopeUuid);
});
_classPrivateFieldInitSpec(this, _startFixture, (name, type) => {
var scopeUuid = (0, _utils.last)(this.scopesStack);
if (scopeUuid) {
this.currentAllureFixtureUuid = this.allureRuntime.startFixture(scopeUuid, type, {
name,
stage: _allureJsCommons.Stage.RUNNING
});
return this.currentAllureFixtureUuid;
}
});
_classPrivateFieldInitSpec(this, _stopFixture, (uuid, error) => {
var statusAndDetails = _classPrivateFieldGet(_resolveStatusWithDetails, this).call(this, error);
this.allureRuntime.updateFixture(uuid, f => Object.assign(f, statusAndDetails));
this.allureRuntime.stopFixture(uuid);
this.currentAllureFixtureUuid = undefined;
});
_classPrivateFieldInitSpec(this, _stopScope, () => {
var scopeUuid = this.scopesStack.pop();
if (scopeUuid) {
this.allureRuntime.writeScope(scopeUuid);
}
});
_classPrivateFieldInitSpec(this, _enableAllureFeatures, () => {
_assertClassBrand(_AllureJasmineReporter_brand, this, _enableAllureFixtures).call(this);
(0, _testplan.enableAllureJasmineTestPlan)();
});
_classPrivateFieldInitSpec(this, _injectFixtureSupportToHookFn, (jasmineHookFn, fixtureType, fixtureName) => (hookImpl, timeout) => jasmineHookFn(
// We use different wrappers here to keep the original length
hookImpl.length === 0 ? _classPrivateFieldGet(_wrapSyncOrPromiseBasedHookInAllureFixture, this).call(this, fixtureType, fixtureName, hookImpl) : _classPrivateFieldGet(_wrapCallbackBasedHookInAllureFixture, this).call(this, fixtureType, fixtureName, hookImpl), timeout));
_classPrivateFieldInitSpec(this, _wrapSyncOrPromiseBasedHookInAllureFixture, (fixtureType, fixtureName, hookImpl) => {
// eslint-disable-next-line @typescript-eslint/no-this-alias
var reporter = this;
return function () {
// Bind hook impl to propagate UserContext
var ctxBoundHookImpl = hookImpl.bind(this);
var fixtureUuid = _classPrivateFieldGet(_startFixture, reporter).call(reporter, fixtureName, fixtureType);
if (!fixtureUuid) {
// No scope started; probably an issue in our code. Just call the hook directly
return ctxBoundHookImpl();
} else {
var maybePromise = _classPrivateFieldGet(_callHookAndStopFixtureOnSyncError, reporter).call(reporter, fixtureUuid, ctxBoundHookImpl);
if ((0, _sdk.isPromise)(maybePromise)) {
return _classPrivateFieldGet(_stopFixtureWhenPromiseIsDone, reporter).call(reporter, fixtureUuid, maybePromise);
}
_classPrivateFieldGet(_stopFixture, reporter).call(reporter, fixtureUuid);
// A sync hook shouldn't return a value. But in case it does, we preserve it and let Jasmine handle it.
return maybePromise;
}
};
});
_classPrivateFieldInitSpec(this, _wrapCallbackBasedHookInAllureFixture, (fixtureType, fixtureName, hookImpl) => {
// eslint-disable-next-line @typescript-eslint/no-this-alias
var reporter = this;
return function (done) {
// Bind hook impl to propagate UserContext
var ctxBoundHookImpl = hookImpl.bind(this);
var fixtureUuid = _classPrivateFieldGet(_startFixture, reporter).call(reporter, fixtureName, fixtureType);
if (!fixtureUuid) {
// No scope started; probably an issue in our code. Just call the hook directly
return ctxBoundHookImpl(done);
} else {
var stopFixtureAndContinue = _classPrivateFieldGet(_injectStopFixtureToHookCallback, reporter).call(reporter, fixtureUuid, done);
// A callback-based hook shouldn't return a value. But in case it does, we preserve it and let Jasmine handle it.
return _classPrivateFieldGet(_callHookAndStopFixtureOnSyncError, reporter).call(reporter, fixtureUuid, ctxBoundHookImpl, stopFixtureAndContinue);
}
};
});
_classPrivateFieldInitSpec(this, _callHookAndStopFixtureOnSyncError, function (fixtureUuid, fn) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
try {
return fn(...args);
} catch (error) {
_classPrivateFieldGet(_stopFixture, _this2).call(_this2, fixtureUuid, error);
throw error;
}
});
_classPrivateFieldInitSpec(this, _stopFixtureWhenPromiseIsDone, (fixtureUuid, hookPromise) => hookPromise.then(value => {
_classPrivateFieldGet(_stopFixture, this).call(this, fixtureUuid);
return value;
}, error => {
_classPrivateFieldGet(_stopFixture, this).call(this, fixtureUuid, error);
throw error;
}));
_classPrivateFieldInitSpec(this, _injectStopFixtureToHookCallback, (fixtureUuid, done) => {
var stopFixtureAndContinue = error => {
_classPrivateFieldGet(_stopFixture, this).call(this, fixtureUuid, error);
// @ts-ignore
done(error);
};
stopFixtureAndContinue.fail = error => {
_classPrivateFieldGet(_stopFixture, this).call(this, fixtureUuid, error !== null && error !== void 0 ? error : "done.fail was called");
done.fail(error);
};
return stopFixtureAndContinue;
});
_classPrivateFieldInitSpec(this, _resolveStatusWithDetails, error => {
if (typeof error === "undefined") {
return {
status: _allureJsCommons.Status.PASSED
};
} else if (typeof error === "string") {
return {
status: _allureJsCommons.Status.BROKEN,
statusDetails: {
message: error
}
};
} else {
return {
status: (0, _sdk.getStatusFromError)(error),
statusDetails: (0, _sdk.getMessageAndTraceFromError)(error)
};
}
});
var _ref = config || {},

@@ -63,7 +207,7 @@ {

(0, _runtime.setGlobalTestRuntime)(testRuntime);
this.installHooks();
_classPrivateFieldGet(_enableAllureFeatures, this).call(this);
// the best place to start global container for hooks and nested suites
var scopeUuid = this.allureRuntime.startScope();
this.scopesStack.push(scopeUuid);
var _scopeUuid = this.allureRuntime.startScope();
this.scopesStack.push(_scopeUuid);
}

@@ -78,7 +222,2 @@ getCurrentSpecPath() {

}
getSpecFullName(spec) {
var specFilename = (spec.filename || "").replace((0, _nodeProcess.cwd)(), "").replace(/^[/\\]/, "");
var specPath = this.getCurrentSpecPath().concat(spec.description).join(" > ");
return "".concat(specFilename, "#").concat(specPath);
}
getAllureInterface() {

@@ -88,6 +227,8 @@ return allure;

handleAllureRuntimeMessages(message) {
if (!this.currentAllureTestUuid) {
var _this$currentAllureFi;
var rootUuid = (_this$currentAllureFi = this.currentAllureFixtureUuid) !== null && _this$currentAllureFi !== void 0 ? _this$currentAllureFi : this.currentAllureTestUuid;
if (!rootUuid) {
return;
}
this.allureRuntime.applyRuntimeMessages(this.currentAllureTestUuid, [message]);
this.allureRuntime.applyRuntimeMessages(rootUuid, [message]);
}

@@ -117,18 +258,23 @@ jasmineStarted() {

this.jasmineSuitesStack.push(suite);
var scopeUuid = this.allureRuntime.startScope();
this.scopesStack.push(scopeUuid);
_classPrivateFieldGet(_startScope, this).call(this);
}
suiteDone() {
this.jasmineSuitesStack.pop();
var scopeUuid = this.scopesStack.pop();
if (scopeUuid) {
this.allureRuntime.writeScope(scopeUuid);
}
_classPrivateFieldGet(_stopScope, this).call(this);
}
specStarted(spec) {
this.currentAllureTestUuid = this.allureRuntime.startTest({
name: spec.description,
fullName: this.getSpecFullName(spec),
stage: _allureJsCommons.Stage.RUNNING
}, this.scopesStack);
var {
fullName,
labels,
name
} = (0, _utils.getAllureNamesAndLabels)(spec.filename, this.getCurrentSpecPath(), spec.description);
if (!(0, _reporter.hasSkipLabel)(labels)) {
_classPrivateFieldGet(_startScope, this).call(this);
this.currentAllureTestUuid = this.allureRuntime.startTest({
name,
fullName,
labels,
stage: _allureJsCommons.Stage.RUNNING
}, this.scopesStack);
}
}

@@ -175,2 +321,3 @@ specDone(spec) {

this.currentAllureTestUuid = undefined;
_classPrivateFieldGet(_stopScope, this).call(this);
}

@@ -186,103 +333,15 @@ jasmineDone() {

}
installHooks() {
var jasmineBeforeAll = global.beforeAll;
var jasmineAfterAll = global.afterAll;
var jasmineBeforeEach = global.beforeEach;
var jasmineAfterEach = global.afterEach;
var wrapJasmineHook = (original, fixtureType, fixtureName) => {
return (action, timeout) => {
original(done => {
var start = Date.now();
var ret;
if (action.length > 0) {
// function takes done callback
ret = new Promise((resolve, reject) => {
var t = resolve;
t.fail = reject;
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
action(t);
});
} else {
ret = action(done);
}
if ((0, _sdk.isPromise)(ret)) {
ret.then(() => {
done();
var scopeUuid = this.scopesStack.length > 0 ? this.scopesStack[this.scopesStack.length - 1] : undefined;
if (scopeUuid) {
var fixtureUuid = this.allureRuntime.startFixture(scopeUuid, fixtureType, {
name: fixtureName,
stage: _allureJsCommons.Stage.FINISHED,
status: _allureJsCommons.Status.PASSED,
start
});
if (fixtureUuid) {
this.allureRuntime.stopFixture(fixtureUuid);
}
}
}).catch(err => {
done.fail(err);
var scopeUuid = this.scopesStack.length > 0 ? this.scopesStack[this.scopesStack.length - 1] : undefined;
if (scopeUuid) {
var fixtureUuid = this.allureRuntime.startFixture(scopeUuid, fixtureType, {
name: fixtureName,
stage: _allureJsCommons.Stage.FINISHED,
status: _allureJsCommons.Status.BROKEN,
start
});
if (fixtureUuid) {
this.allureRuntime.stopFixture(fixtureUuid);
}
}
});
} else {
try {
done();
var scopeUuid = this.scopesStack.length > 0 ? this.scopesStack[this.scopesStack.length - 1] : undefined;
if (scopeUuid) {
var fixtureUuid = this.allureRuntime.startFixture(scopeUuid, fixtureType, {
name: fixtureName,
stage: _allureJsCommons.Stage.FINISHED,
status: _allureJsCommons.Status.PASSED,
start
});
if (fixtureUuid) {
this.allureRuntime.stopFixture(fixtureUuid);
}
}
} catch (err) {
var {
message,
stack
} = err;
var _scopeUuid = this.scopesStack.length > 0 ? this.scopesStack[this.scopesStack.length - 1] : undefined;
if (_scopeUuid) {
var _fixtureUuid = this.allureRuntime.startFixture(_scopeUuid, fixtureType, {
name: fixtureName,
stage: _allureJsCommons.Stage.FINISHED,
status: _allureJsCommons.Status.BROKEN,
statusDetails: {
message,
trace: stack
},
start
});
if (_fixtureUuid) {
this.allureRuntime.stopFixture(_fixtureUuid);
}
}
throw err;
}
}
}, timeout);
};
};
global.beforeAll = wrapJasmineHook(jasmineBeforeAll, "before", "beforeAll");
global.beforeEach = wrapJasmineHook(jasmineBeforeEach, "before", "beforeEach");
global.afterAll = wrapJasmineHook(jasmineAfterAll, "after", "afterAll");
global.afterEach = wrapJasmineHook(jasmineAfterEach, "after", "afterEach");
}
}
exports.default = AllureJasmineReporter;
function _enableAllureFixtures() {
var jasmineBeforeAll = global.beforeAll;
var jasmineAfterAll = global.afterAll;
var jasmineBeforeEach = global.beforeEach;
var jasmineAfterEach = global.afterEach;
global.beforeAll = _classPrivateFieldGet(_injectFixtureSupportToHookFn, this).call(this, jasmineBeforeAll, "before", "beforeAll");
global.beforeEach = _classPrivateFieldGet(_injectFixtureSupportToHookFn, this).call(this, jasmineBeforeEach, "before", "beforeEach");
global.afterAll = _classPrivateFieldGet(_injectFixtureSupportToHookFn, this).call(this, jasmineAfterAll, "after", "afterAll");
global.afterEach = _classPrivateFieldGet(_injectFixtureSupportToHookFn, this).call(this, jasmineAfterEach, "after", "afterEach");
}
module.exports = exports.default;
//# sourceMappingURL=index.js.map

@@ -6,4 +6,5 @@ "use strict";

});
exports.findMessageAboutThrow = exports.findAnyError = void 0;
// eslint-disable-next-line no-undef
exports.last = exports.getAllureNamesAndLabels = exports.findMessageAboutThrow = exports.findAnyError = void 0;
var _nodeProcess = require("node:process");
var _sdk = require("allure-js-commons/sdk");
var FailedExpectation = jasmine.FailedExpectation;

@@ -22,2 +23,18 @@ var findAnyError = expectations => {

exports.findMessageAboutThrow = findMessageAboutThrow;
var last = arr => arr.length ? arr[arr.length - 1] : undefined;
exports.last = last;
var getAllureNamesAndLabels = (filename, suites, rawSpecName) => {
var filePart = (filename || "").replace((0, _nodeProcess.cwd)(), "").replace(/^[/\\]/, "");
var {
cleanTitle: specName,
labels
} = (0, _sdk.extractMetadataFromString)(rawSpecName);
var specPart = [...suites, specName].join(" > ");
return {
name: specName,
fullName: "".concat(filePart, "#").concat(specPart),
labels
};
};
exports.getAllureNamesAndLabels = getAllureNamesAndLabels;
//# sourceMappingURL=utils.js.map

@@ -6,14 +6,20 @@ var _excluded = ["resultsDir"];

function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
import { cwd, env } from "node:process";
import { env } from "node:process";
import * as allure from "allure-js-commons";
import { Stage, Status } from "allure-js-commons";
import { isPromise } from "allure-js-commons/sdk";
import { FileSystemWriter, MessageWriter, ReporterRuntime, getEnvironmentLabels, getSuiteLabels } from "allure-js-commons/sdk/reporter";
import { getMessageAndTraceFromError, getStatusFromError, isPromise } from "allure-js-commons/sdk";
import { FileSystemWriter, MessageWriter, ReporterRuntime, getEnvironmentLabels, getSuiteLabels, hasSkipLabel } from "allure-js-commons/sdk/reporter";
import { MessageTestRuntime, setGlobalTestRuntime } from "allure-js-commons/sdk/runtime";
import { findAnyError, findMessageAboutThrow } from "./utils.js";
import { enableAllureJasmineTestPlan } from "./testplan.js";
import { findAnyError, findMessageAboutThrow, getAllureNamesAndLabels, last } from "./utils.js";
class AllureJasmineTestRuntime extends MessageTestRuntime {

@@ -35,8 +41,146 @@ constructor(allureJasmineReporter) {

} = env;
var _startScope = /*#__PURE__*/new WeakMap();
var _startFixture = /*#__PURE__*/new WeakMap();
var _stopFixture = /*#__PURE__*/new WeakMap();
var _stopScope = /*#__PURE__*/new WeakMap();
var _enableAllureFeatures = /*#__PURE__*/new WeakMap();
var _AllureJasmineReporter_brand = /*#__PURE__*/new WeakSet();
var _injectFixtureSupportToHookFn = /*#__PURE__*/new WeakMap();
var _wrapSyncOrPromiseBasedHookInAllureFixture = /*#__PURE__*/new WeakMap();
var _wrapCallbackBasedHookInAllureFixture = /*#__PURE__*/new WeakMap();
var _callHookAndStopFixtureOnSyncError = /*#__PURE__*/new WeakMap();
var _stopFixtureWhenPromiseIsDone = /*#__PURE__*/new WeakMap();
var _injectStopFixtureToHookCallback = /*#__PURE__*/new WeakMap();
var _resolveStatusWithDetails = /*#__PURE__*/new WeakMap();
export default class AllureJasmineReporter {
constructor(config) {
var _this2 = this;
_classPrivateMethodInitSpec(this, _AllureJasmineReporter_brand);
_defineProperty(this, "allureRuntime", void 0);
_defineProperty(this, "currentAllureTestUuid", void 0);
_defineProperty(this, "currentAllureFixtureUuid", void 0);
_defineProperty(this, "jasmineSuitesStack", []);
_defineProperty(this, "scopesStack", []);
_classPrivateFieldInitSpec(this, _startScope, () => {
var scopeUuid = this.allureRuntime.startScope();
this.scopesStack.push(scopeUuid);
});
_classPrivateFieldInitSpec(this, _startFixture, (name, type) => {
var scopeUuid = last(this.scopesStack);
if (scopeUuid) {
this.currentAllureFixtureUuid = this.allureRuntime.startFixture(scopeUuid, type, {
name,
stage: Stage.RUNNING
});
return this.currentAllureFixtureUuid;
}
});
_classPrivateFieldInitSpec(this, _stopFixture, (uuid, error) => {
var statusAndDetails = _classPrivateFieldGet(_resolveStatusWithDetails, this).call(this, error);
this.allureRuntime.updateFixture(uuid, f => Object.assign(f, statusAndDetails));
this.allureRuntime.stopFixture(uuid);
this.currentAllureFixtureUuid = undefined;
});
_classPrivateFieldInitSpec(this, _stopScope, () => {
var scopeUuid = this.scopesStack.pop();
if (scopeUuid) {
this.allureRuntime.writeScope(scopeUuid);
}
});
_classPrivateFieldInitSpec(this, _enableAllureFeatures, () => {
_assertClassBrand(_AllureJasmineReporter_brand, this, _enableAllureFixtures).call(this);
enableAllureJasmineTestPlan();
});
_classPrivateFieldInitSpec(this, _injectFixtureSupportToHookFn, (jasmineHookFn, fixtureType, fixtureName) => (hookImpl, timeout) => jasmineHookFn(
// We use different wrappers here to keep the original length
hookImpl.length === 0 ? _classPrivateFieldGet(_wrapSyncOrPromiseBasedHookInAllureFixture, this).call(this, fixtureType, fixtureName, hookImpl) : _classPrivateFieldGet(_wrapCallbackBasedHookInAllureFixture, this).call(this, fixtureType, fixtureName, hookImpl), timeout));
_classPrivateFieldInitSpec(this, _wrapSyncOrPromiseBasedHookInAllureFixture, (fixtureType, fixtureName, hookImpl) => {
// eslint-disable-next-line @typescript-eslint/no-this-alias
var reporter = this;
return function () {
// Bind hook impl to propagate UserContext
var ctxBoundHookImpl = hookImpl.bind(this);
var fixtureUuid = _classPrivateFieldGet(_startFixture, reporter).call(reporter, fixtureName, fixtureType);
if (!fixtureUuid) {
// No scope started; probably an issue in our code. Just call the hook directly
return ctxBoundHookImpl();
} else {
var maybePromise = _classPrivateFieldGet(_callHookAndStopFixtureOnSyncError, reporter).call(reporter, fixtureUuid, ctxBoundHookImpl);
if (isPromise(maybePromise)) {
return _classPrivateFieldGet(_stopFixtureWhenPromiseIsDone, reporter).call(reporter, fixtureUuid, maybePromise);
}
_classPrivateFieldGet(_stopFixture, reporter).call(reporter, fixtureUuid);
// A sync hook shouldn't return a value. But in case it does, we preserve it and let Jasmine handle it.
return maybePromise;
}
};
});
_classPrivateFieldInitSpec(this, _wrapCallbackBasedHookInAllureFixture, (fixtureType, fixtureName, hookImpl) => {
// eslint-disable-next-line @typescript-eslint/no-this-alias
var reporter = this;
return function (done) {
// Bind hook impl to propagate UserContext
var ctxBoundHookImpl = hookImpl.bind(this);
var fixtureUuid = _classPrivateFieldGet(_startFixture, reporter).call(reporter, fixtureName, fixtureType);
if (!fixtureUuid) {
// No scope started; probably an issue in our code. Just call the hook directly
return ctxBoundHookImpl(done);
} else {
var stopFixtureAndContinue = _classPrivateFieldGet(_injectStopFixtureToHookCallback, reporter).call(reporter, fixtureUuid, done);
// A callback-based hook shouldn't return a value. But in case it does, we preserve it and let Jasmine handle it.
return _classPrivateFieldGet(_callHookAndStopFixtureOnSyncError, reporter).call(reporter, fixtureUuid, ctxBoundHookImpl, stopFixtureAndContinue);
}
};
});
_classPrivateFieldInitSpec(this, _callHookAndStopFixtureOnSyncError, function (fixtureUuid, fn) {
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
try {
return fn(...args);
} catch (error) {
_classPrivateFieldGet(_stopFixture, _this2).call(_this2, fixtureUuid, error);
throw error;
}
});
_classPrivateFieldInitSpec(this, _stopFixtureWhenPromiseIsDone, (fixtureUuid, hookPromise) => hookPromise.then(value => {
_classPrivateFieldGet(_stopFixture, this).call(this, fixtureUuid);
return value;
}, error => {
_classPrivateFieldGet(_stopFixture, this).call(this, fixtureUuid, error);
throw error;
}));
_classPrivateFieldInitSpec(this, _injectStopFixtureToHookCallback, (fixtureUuid, done) => {
var stopFixtureAndContinue = error => {
_classPrivateFieldGet(_stopFixture, this).call(this, fixtureUuid, error);
// @ts-ignore
done(error);
};
stopFixtureAndContinue.fail = error => {
_classPrivateFieldGet(_stopFixture, this).call(this, fixtureUuid, error !== null && error !== void 0 ? error : "done.fail was called");
done.fail(error);
};
return stopFixtureAndContinue;
});
_classPrivateFieldInitSpec(this, _resolveStatusWithDetails, error => {
if (typeof error === "undefined") {
return {
status: Status.PASSED
};
} else if (typeof error === "string") {
return {
status: Status.BROKEN,
statusDetails: {
message: error
}
};
} else {
return {
status: getStatusFromError(error),
statusDetails: getMessageAndTraceFromError(error)
};
}
});
var _ref = config || {},

@@ -54,7 +198,7 @@ {

setGlobalTestRuntime(testRuntime);
this.installHooks();
_classPrivateFieldGet(_enableAllureFeatures, this).call(this);
// the best place to start global container for hooks and nested suites
var scopeUuid = this.allureRuntime.startScope();
this.scopesStack.push(scopeUuid);
var _scopeUuid = this.allureRuntime.startScope();
this.scopesStack.push(_scopeUuid);
}

@@ -69,7 +213,2 @@ getCurrentSpecPath() {

}
getSpecFullName(spec) {
var specFilename = (spec.filename || "").replace(cwd(), "").replace(/^[/\\]/, "");
var specPath = this.getCurrentSpecPath().concat(spec.description).join(" > ");
return "".concat(specFilename, "#").concat(specPath);
}
getAllureInterface() {

@@ -79,6 +218,8 @@ return allure;

handleAllureRuntimeMessages(message) {
if (!this.currentAllureTestUuid) {
var _this$currentAllureFi;
var rootUuid = (_this$currentAllureFi = this.currentAllureFixtureUuid) !== null && _this$currentAllureFi !== void 0 ? _this$currentAllureFi : this.currentAllureTestUuid;
if (!rootUuid) {
return;
}
this.allureRuntime.applyRuntimeMessages(this.currentAllureTestUuid, [message]);
this.allureRuntime.applyRuntimeMessages(rootUuid, [message]);
}

@@ -108,18 +249,23 @@ jasmineStarted() {

this.jasmineSuitesStack.push(suite);
var scopeUuid = this.allureRuntime.startScope();
this.scopesStack.push(scopeUuid);
_classPrivateFieldGet(_startScope, this).call(this);
}
suiteDone() {
this.jasmineSuitesStack.pop();
var scopeUuid = this.scopesStack.pop();
if (scopeUuid) {
this.allureRuntime.writeScope(scopeUuid);
}
_classPrivateFieldGet(_stopScope, this).call(this);
}
specStarted(spec) {
this.currentAllureTestUuid = this.allureRuntime.startTest({
name: spec.description,
fullName: this.getSpecFullName(spec),
stage: Stage.RUNNING
}, this.scopesStack);
var {
fullName,
labels,
name
} = getAllureNamesAndLabels(spec.filename, this.getCurrentSpecPath(), spec.description);
if (!hasSkipLabel(labels)) {
_classPrivateFieldGet(_startScope, this).call(this);
this.currentAllureTestUuid = this.allureRuntime.startTest({
name,
fullName,
labels,
stage: Stage.RUNNING
}, this.scopesStack);
}
}

@@ -166,2 +312,3 @@ specDone(spec) {

this.currentAllureTestUuid = undefined;
_classPrivateFieldGet(_stopScope, this).call(this);
}

@@ -177,101 +324,13 @@ jasmineDone() {

}
installHooks() {
var jasmineBeforeAll = global.beforeAll;
var jasmineAfterAll = global.afterAll;
var jasmineBeforeEach = global.beforeEach;
var jasmineAfterEach = global.afterEach;
var wrapJasmineHook = (original, fixtureType, fixtureName) => {
return (action, timeout) => {
original(done => {
var start = Date.now();
var ret;
if (action.length > 0) {
// function takes done callback
ret = new Promise((resolve, reject) => {
var t = resolve;
t.fail = reject;
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
action(t);
});
} else {
ret = action(done);
}
if (isPromise(ret)) {
ret.then(() => {
done();
var scopeUuid = this.scopesStack.length > 0 ? this.scopesStack[this.scopesStack.length - 1] : undefined;
if (scopeUuid) {
var fixtureUuid = this.allureRuntime.startFixture(scopeUuid, fixtureType, {
name: fixtureName,
stage: Stage.FINISHED,
status: Status.PASSED,
start
});
if (fixtureUuid) {
this.allureRuntime.stopFixture(fixtureUuid);
}
}
}).catch(err => {
done.fail(err);
var scopeUuid = this.scopesStack.length > 0 ? this.scopesStack[this.scopesStack.length - 1] : undefined;
if (scopeUuid) {
var fixtureUuid = this.allureRuntime.startFixture(scopeUuid, fixtureType, {
name: fixtureName,
stage: Stage.FINISHED,
status: Status.BROKEN,
start
});
if (fixtureUuid) {
this.allureRuntime.stopFixture(fixtureUuid);
}
}
});
} else {
try {
done();
var scopeUuid = this.scopesStack.length > 0 ? this.scopesStack[this.scopesStack.length - 1] : undefined;
if (scopeUuid) {
var fixtureUuid = this.allureRuntime.startFixture(scopeUuid, fixtureType, {
name: fixtureName,
stage: Stage.FINISHED,
status: Status.PASSED,
start
});
if (fixtureUuid) {
this.allureRuntime.stopFixture(fixtureUuid);
}
}
} catch (err) {
var {
message,
stack
} = err;
var _scopeUuid = this.scopesStack.length > 0 ? this.scopesStack[this.scopesStack.length - 1] : undefined;
if (_scopeUuid) {
var _fixtureUuid = this.allureRuntime.startFixture(_scopeUuid, fixtureType, {
name: fixtureName,
stage: Stage.FINISHED,
status: Status.BROKEN,
statusDetails: {
message,
trace: stack
},
start
});
if (_fixtureUuid) {
this.allureRuntime.stopFixture(_fixtureUuid);
}
}
throw err;
}
}
}, timeout);
};
};
global.beforeAll = wrapJasmineHook(jasmineBeforeAll, "before", "beforeAll");
global.beforeEach = wrapJasmineHook(jasmineBeforeEach, "before", "beforeEach");
global.afterAll = wrapJasmineHook(jasmineAfterAll, "after", "afterAll");
global.afterEach = wrapJasmineHook(jasmineAfterEach, "after", "afterEach");
}
}
function _enableAllureFixtures() {
var jasmineBeforeAll = global.beforeAll;
var jasmineAfterAll = global.afterAll;
var jasmineBeforeEach = global.beforeEach;
var jasmineAfterEach = global.afterEach;
global.beforeAll = _classPrivateFieldGet(_injectFixtureSupportToHookFn, this).call(this, jasmineBeforeAll, "before", "beforeAll");
global.beforeEach = _classPrivateFieldGet(_injectFixtureSupportToHookFn, this).call(this, jasmineBeforeEach, "before", "beforeEach");
global.afterAll = _classPrivateFieldGet(_injectFixtureSupportToHookFn, this).call(this, jasmineAfterAll, "after", "afterAll");
global.afterEach = _classPrivateFieldGet(_injectFixtureSupportToHookFn, this).call(this, jasmineAfterEach, "after", "afterEach");
}
//# sourceMappingURL=index.js.map

@@ -1,2 +0,3 @@

// eslint-disable-next-line no-undef
import { cwd } from "node:process";
import { extractMetadataFromString } from "allure-js-commons/sdk";
var FailedExpectation = jasmine.FailedExpectation;

@@ -13,2 +14,16 @@ export var findAnyError = expectations => {

};
export var last = arr => arr.length ? arr[arr.length - 1] : undefined;
export var getAllureNamesAndLabels = (filename, suites, rawSpecName) => {
var filePart = (filename || "").replace(cwd(), "").replace(/^[/\\]/, "");
var {
cleanTitle: specName,
labels
} = extractMetadataFromString(rawSpecName);
var specPart = [...suites, specName].join(" > ");
return {
name: specName,
fullName: "".concat(filePart, "#").concat(specPart),
labels
};
};
//# sourceMappingURL=utils.js.map

@@ -6,4 +6,6 @@ /// <reference types="jasmine" />

export default class AllureJasmineReporter implements jasmine.CustomReporter {
#private;
private readonly allureRuntime;
private currentAllureTestUuid?;
private currentAllureFixtureUuid?;
private jasmineSuitesStack;

@@ -13,3 +15,2 @@ private scopesStack;

private getCurrentSpecPath;
private getSpecFullName;
getAllureInterface(): typeof allure;

@@ -20,6 +21,7 @@ handleAllureRuntimeMessages(message: RuntimeMessage): void;

suiteDone(): void;
specStarted(spec: jasmine.SpecResult): void;
specStarted(spec: jasmine.SpecResult & {
filename?: string;
}): void;
specDone(spec: jasmine.SpecResult): void;
jasmineDone(): void;
private installHooks;
}

@@ -1,2 +0,7 @@

/// <reference types="jasmine" />
export type JasmineBeforeAfterFn = (action: (done: DoneFn) => void, timeout?: number) => void;
export type JasmineBeforeAfterFn = typeof global.beforeEach;
export type JasmineSpecFn = typeof global.it;
export type JasmineSuiteFn = typeof global.describe;
export type TestPlanIndex = {
ids: ReadonlySet<string>;
fullNames: ReadonlySet<string>;
};

@@ -5,1 +5,7 @@ /// <reference types="jasmine" />

export declare const findMessageAboutThrow: (expectations?: FailedExpectation[]) => FailedExpectation | undefined;
export declare const last: <T>(arr: readonly T[]) => T | undefined;
export declare const getAllureNamesAndLabels: (filename: string | undefined, suites: readonly string[], rawSpecName: string) => {
name: string;
fullName: string;
labels: import("allure-js-commons").Label[];
};
{
"name": "allure-jasmine",
"version": "3.0.0-beta.6",
"version": "3.0.0-beta.7",
"description": "Allure Jasmine integration",

@@ -43,3 +43,3 @@ "homepage": "https://allurereport.org/",

"dependencies": {
"allure-js-commons": "3.0.0-beta.6"
"allure-js-commons": "3.0.0-beta.7"
},

@@ -59,4 +59,5 @@ "devDependencies": {

"allure-commandline": "^2.29.0",
"allure-vitest": "3.0.0-beta.6",
"allure-vitest": "3.0.0-beta.7",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-transform-import-meta": "^2.2.1",
"eslint": "^8.57.0",

@@ -71,3 +72,3 @@ "eslint-config-prettier": "^9.0.0",

"npm-run-all2": "^6.1.2",
"rimraf": "^5.0.1",
"rimraf": "^6.0.0",
"typescript": "^5.2.2",

@@ -74,0 +75,0 @@ "vitest": "^1.6.0"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc