allure-js-commons
Advanced tools
Comparing version 3.0.0-beta.10 to 3.0.0-beta.11
@@ -17,3 +17,6 @@ "use strict"; | ||
getHostLabel: true, | ||
getThreadLabel: true | ||
getThreadLabel: true, | ||
getPackageLabel: true, | ||
getLanguageLabel: true, | ||
getFrameworkLabel: true | ||
}; | ||
@@ -74,2 +77,8 @@ Object.defineProperty(exports, "ALLURE_METADATA_CONTENT_TYPE", { | ||
}); | ||
Object.defineProperty(exports, "getFrameworkLabel", { | ||
enumerable: true, | ||
get: function get() { | ||
return _labels.getFrameworkLabel; | ||
} | ||
}); | ||
Object.defineProperty(exports, "getHostLabel", { | ||
@@ -81,2 +90,14 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "getLanguageLabel", { | ||
enumerable: true, | ||
get: function get() { | ||
return _labels.getLanguageLabel; | ||
} | ||
}); | ||
Object.defineProperty(exports, "getPackageLabel", { | ||
enumerable: true, | ||
get: function get() { | ||
return _labels.getPackageLabel; | ||
} | ||
}); | ||
Object.defineProperty(exports, "getThreadLabel", { | ||
@@ -83,0 +104,0 @@ enumerable: true, |
@@ -12,11 +12,19 @@ "use strict"; | ||
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 _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 _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"); } | ||
var _scopes = /*#__PURE__*/new WeakMap(); | ||
var _testResults = /*#__PURE__*/new WeakMap(); | ||
var _stepResults = /*#__PURE__*/new WeakMap(); | ||
var _fixturesResults = /*#__PURE__*/new WeakMap(); | ||
class LifecycleState { | ||
constructor() { | ||
var _this = this; | ||
_defineProperty(this, "scopes", new Map()); | ||
_defineProperty(this, "testResults", new Map()); | ||
_defineProperty(this, "stepResults", new Map()); | ||
_defineProperty(this, "fixturesResults", new Map()); | ||
_defineProperty(this, "getScope", uuid => this.scopes.get(uuid)); | ||
_defineProperty(this, "getWrappedFixtureResult", uuid => this.fixturesResults.get(uuid)); | ||
_classPrivateFieldInitSpec(this, _scopes, new Map()); | ||
_classPrivateFieldInitSpec(this, _testResults, new Map()); | ||
_classPrivateFieldInitSpec(this, _stepResults, new Map()); | ||
_classPrivateFieldInitSpec(this, _fixturesResults, new Map()); | ||
_defineProperty(this, "getScope", uuid => _classPrivateFieldGet(_scopes, this).get(uuid)); | ||
_defineProperty(this, "getWrappedFixtureResult", uuid => _classPrivateFieldGet(_fixturesResults, this).get(uuid)); | ||
_defineProperty(this, "getFixtureResult", uuid => { | ||
@@ -26,4 +34,8 @@ var _this$getWrappedFixtu; | ||
}); | ||
_defineProperty(this, "getTestResult", uuid => this.testResults.get(uuid)); | ||
_defineProperty(this, "getStepResult", uuid => this.stepResults.get(uuid)); | ||
_defineProperty(this, "getWrappedTestResult", uuid => _classPrivateFieldGet(_testResults, this).get(uuid)); | ||
_defineProperty(this, "getTestResult", uuid => { | ||
var _this$getWrappedTestR; | ||
return (_this$getWrappedTestR = this.getWrappedTestResult(uuid)) === null || _this$getWrappedTestR === void 0 ? void 0 : _this$getWrappedTestR.value; | ||
}); | ||
_defineProperty(this, "getStepResult", uuid => _classPrivateFieldGet(_stepResults, this).get(uuid)); | ||
_defineProperty(this, "getExecutionItem", uuid => { | ||
@@ -34,27 +46,32 @@ var _ref, _this$getFixtureResul; | ||
// test results | ||
_defineProperty(this, "setTestResult", (uuid, result) => { | ||
this.testResults.set(uuid, result); | ||
_defineProperty(this, "setTestResult", function (uuid, result) { | ||
var scopeUuids = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
_classPrivateFieldGet(_testResults, _this).set(uuid, { | ||
value: result, | ||
scopeUuids | ||
}); | ||
}); | ||
_defineProperty(this, "deleteTestResult", uuid => { | ||
this.testResults.delete(uuid); | ||
_classPrivateFieldGet(_testResults, this).delete(uuid); | ||
}); | ||
// steps | ||
_defineProperty(this, "setStepResult", (uuid, result) => { | ||
this.stepResults.set(uuid, result); | ||
_classPrivateFieldGet(_stepResults, this).set(uuid, result); | ||
}); | ||
_defineProperty(this, "deleteStepResult", uuid => { | ||
this.stepResults.delete(uuid); | ||
_classPrivateFieldGet(_stepResults, this).delete(uuid); | ||
}); | ||
// fixtures | ||
_defineProperty(this, "setFixtureResult", (uuid, type, result) => { | ||
_defineProperty(this, "setFixtureResult", (scopeUuid, uuid, type, result) => { | ||
var wrappedResult = { | ||
uuid, | ||
type, | ||
value: result | ||
value: result, | ||
scopeUuid | ||
}; | ||
this.fixturesResults.set(uuid, wrappedResult); | ||
_classPrivateFieldGet(_fixturesResults, this).set(uuid, wrappedResult); | ||
return wrappedResult; | ||
}); | ||
_defineProperty(this, "deleteFixtureResult", uuid => { | ||
this.fixturesResults.delete(uuid); | ||
_classPrivateFieldGet(_fixturesResults, this).delete(uuid); | ||
}); | ||
@@ -65,2 +82,5 @@ // test scopes | ||
var scope = _objectSpread(_objectSpread({ | ||
labels: [], | ||
links: [], | ||
parameters: [], | ||
fixtures: [], | ||
@@ -71,7 +91,7 @@ tests: [] | ||
}); | ||
_this.scopes.set(uuid, scope); | ||
_classPrivateFieldGet(_scopes, _this).set(uuid, scope); | ||
return scope; | ||
}); | ||
_defineProperty(this, "deleteScope", uuid => { | ||
this.scopes.delete(uuid); | ||
_classPrivateFieldGet(_scopes, this).delete(uuid); | ||
}); | ||
@@ -78,0 +98,0 @@ } |
@@ -16,5 +16,2 @@ "use strict"; | ||
var _loader = require("./writer/loader.js"); | ||
var _excluded = ["links", "labels", "parameters", "displayName"]; | ||
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } | ||
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 ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } | ||
@@ -133,3 +130,3 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } | ||
var uuid = (0, _utils.randomUuid)(); | ||
var wrappedFixture = this.state.setFixtureResult(uuid, type, _objectSpread(_objectSpread({}, (0, _factory.createFixtureResult)()), {}, { | ||
var wrappedFixture = this.state.setFixtureResult(scopeUuid, uuid, type, _objectSpread(_objectSpread({}, (0, _factory.createFixtureResult)()), {}, { | ||
start: Date.now() | ||
@@ -177,3 +174,3 @@ }, fixtureResult)); | ||
}); | ||
_this.state.setTestResult(uuid, testResult); | ||
_this.state.setTestResult(uuid, testResult, scopeUuids); | ||
_this.notifier.afterTestResultStart(testResult); | ||
@@ -195,4 +192,4 @@ return uuid; | ||
var _testResult$testCaseI, _testResult$historyId; | ||
var testResult = this.state.getTestResult(uuid); | ||
if (!testResult) { | ||
var wrapped = this.state.getWrappedTestResult(uuid); | ||
if (!wrapped) { | ||
// eslint-disable-next-line no-console | ||
@@ -202,2 +199,3 @@ console.error("could not stop test result: no test with uuid ".concat(uuid, ") is found")); | ||
} | ||
var testResult = wrapped.value; | ||
this.notifier.beforeTestResultStop(testResult); | ||
@@ -209,6 +207,13 @@ (_testResult$testCaseI = testResult.testCaseId) !== null && _testResult$testCaseI !== void 0 ? _testResult$testCaseI : testResult.testCaseId = (0, _utils.getTestResultTestCaseId)(testResult); | ||
testResult.stop = startStop.stop; | ||
var scopeUuids = wrapped.scopeUuids; | ||
scopeUuids.forEach(scopeUuid => { | ||
var scope = this.state.getScope(scopeUuid); | ||
if (scope !== null && scope !== void 0 && scope.labels) { | ||
testResult.labels = [...testResult.labels, ...scope.labels]; | ||
} | ||
}); | ||
this.notifier.afterTestResultStop(testResult); | ||
}); | ||
_defineProperty(this, "writeTest", uuid => { | ||
var testResult = this.state.testResults.get(uuid); | ||
var testResult = this.state.getTestResult(uuid); | ||
if (!testResult) { | ||
@@ -360,18 +365,56 @@ // eslint-disable-next-line no-console | ||
// only display name could be set to fixture. | ||
var fixtureResult = this.state.getFixtureResult(rootUuid); | ||
var fixtureResult = this.state.getWrappedFixtureResult(rootUuid); | ||
var { | ||
links, | ||
labels, | ||
parameters, | ||
displayName, | ||
testCaseId, | ||
historyId, | ||
description, | ||
descriptionHtml | ||
} = message; | ||
if (fixtureResult) { | ||
this.updateFixture(rootUuid, result => { | ||
if (message.displayName) { | ||
result.name = message.displayName; | ||
if (displayName) { | ||
this.updateFixture(rootUuid, result => { | ||
result.name = displayName; | ||
}); | ||
} | ||
if (historyId) { | ||
// eslint-disable-next-line no-console | ||
console.error("historyId can't be changed within test fixtures"); | ||
} | ||
if (testCaseId) { | ||
// eslint-disable-next-line no-console | ||
console.error("testCaseId can't be changed within test fixtures"); | ||
} | ||
if (links || labels || parameters || description || descriptionHtml) { | ||
// in some frameworks, afterEach methods can be executed before test stop event, while | ||
// in others after. To remove the possible undetermined behaviour we only allow | ||
// using runtime metadata API in before hooks. | ||
if (fixtureResult.type === "after") { | ||
// eslint-disable-next-line no-console | ||
console.error("metadata messages isn't supported for after test fixtures"); | ||
return; | ||
} | ||
}); | ||
this.updateScope(fixtureResult.scopeUuid, scope => { | ||
if (links) { | ||
scope.links = [...scope.links, ...(this.linkConfig ? (0, _utils.formatLinks)(this.linkConfig, links) : links)]; | ||
} | ||
if (labels) { | ||
scope.labels = [...scope.labels, ...labels]; | ||
} | ||
if (parameters) { | ||
scope.parameters = [...scope.parameters, ...parameters]; | ||
} | ||
if (description) { | ||
scope.description = description; | ||
} | ||
if (descriptionHtml) { | ||
scope.descriptionHtml = descriptionHtml; | ||
} | ||
}); | ||
} | ||
return; | ||
} | ||
var { | ||
links, | ||
labels, | ||
parameters, | ||
displayName | ||
} = message, | ||
rest = _objectWithoutProperties(message, _excluded); | ||
this.updateTest(rootUuid, result => { | ||
@@ -390,3 +433,14 @@ if (links) { | ||
} | ||
Object.assign(result, rest); | ||
if (testCaseId) { | ||
result.testCaseId = testCaseId; | ||
} | ||
if (historyId) { | ||
result.historyId = historyId; | ||
} | ||
if (description) { | ||
result.description = description; | ||
} | ||
if (descriptionHtml) { | ||
result.descriptionHtml = descriptionHtml; | ||
} | ||
}); | ||
@@ -393,0 +447,0 @@ }); |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.stringifyProperties = exports.serialize = exports.readImageAsBase64 = exports.randomUuid = exports.parseProperties = exports.md5 = exports.getWorstStepResultStatusPriority = exports.getWorstStepResultStatus = exports.getTestResultTestCaseId = exports.getTestResultHistoryId = exports.getSuiteLabels = exports.getRelativePath = exports.getPackageLabelFromPath = exports.formatLinks = exports.formatLink = exports.escapeRegExp = exports.ensureSuiteLabels = exports.deepClone = exports.createDefaultWriter = exports.applyLinkTemplate = void 0; | ||
exports.stringifyProperties = exports.serialize = exports.readImageAsBase64 = exports.randomUuid = exports.parseProperties = exports.md5 = exports.getWorstStepResultStatusPriority = exports.getWorstStepResultStatus = exports.getTestResultTestCaseId = exports.getTestResultHistoryId = exports.getSuiteLabels = exports.getRelativePath = exports.formatLinks = exports.formatLink = exports.escapeRegExp = exports.ensureSuiteLabels = exports.deepClone = exports.createDefaultWriter = exports.applyLinkTemplate = void 0; | ||
var _promises = require("fs/promises"); | ||
@@ -140,7 +140,2 @@ var _nodeCrypto = require("node:crypto"); | ||
exports.getRelativePath = getRelativePath; | ||
var getPackageLabelFromPath = filepath => ({ | ||
name: _model.LabelName.PACKAGE, | ||
value: getRelativePath(filepath).split(_nodePath.default.sep).filter(v => v).join(".") | ||
}); | ||
exports.getPackageLabelFromPath = getPackageLabelFromPath; | ||
var deepClone = obj => JSON.parse(JSON.stringify(obj)); | ||
@@ -147,0 +142,0 @@ exports.deepClone = deepClone; |
@@ -6,7 +6,10 @@ "use strict"; | ||
}); | ||
exports.getThreadLabel = exports.getHostLabel = exports.getEnvironmentLabels = void 0; | ||
exports.getThreadLabel = exports.getPackageLabel = exports.getLanguageLabel = exports.getHostLabel = exports.getFrameworkLabel = exports.getEnvironmentLabels = void 0; | ||
var _nodeOs = require("node:os"); | ||
var _nodePath = _interopRequireDefault(require("node:path")); | ||
var _nodeProcess = require("node:process"); | ||
var _nodeWorker_threads = require("node:worker_threads"); | ||
var _model = require("../../../model.js"); | ||
var _utils = require("../utils.js"); | ||
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } | ||
var ENV_LABEL_PREFIX = "ALLURE_LABEL_"; | ||
@@ -49,2 +52,17 @@ var getEnvironmentLabels = () => { | ||
exports.getThreadLabel = getThreadLabel; | ||
var getPackageLabel = filepath => ({ | ||
name: _model.LabelName.PACKAGE, | ||
value: (0, _utils.getRelativePath)(filepath).split(_nodePath.default.sep).filter(v => v).join(".") | ||
}); | ||
exports.getPackageLabel = getPackageLabel; | ||
var getLanguageLabel = () => ({ | ||
name: _model.LabelName.LANGUAGE, | ||
value: "javascript" | ||
}); | ||
exports.getLanguageLabel = getLanguageLabel; | ||
var getFrameworkLabel = framework => ({ | ||
name: _model.LabelName.FRAMEWORK, | ||
value: framework | ||
}); | ||
exports.getFrameworkLabel = getFrameworkLabel; | ||
//# sourceMappingURL=labels.js.map |
@@ -17,2 +17,3 @@ "use strict"; | ||
* `jasmine` throws `ExpectationFailed` instance | ||
* `vitest` throws `Error` for extended assertions, so we look into stack | ||
*/ | ||
@@ -23,2 +24,3 @@ case /assert/gi.test(error.constructor.name): | ||
case /assert/gi.test(error.message): | ||
case error.stack && /@vitest\/expect/gi.test(error.stack): | ||
return _model.Status.FAILED; | ||
@@ -25,0 +27,0 @@ default: |
@@ -11,3 +11,3 @@ export { ALLURE_METADATA_CONTENT_TYPE, ALLURE_RUNTIME_MESSAGE_CONTENT_TYPE } from "./types.js"; | ||
export { MessageReader } from "./writer/MessageReader.js"; | ||
export { getEnvironmentLabels, getHostLabel, getThreadLabel } from "./utils/labels.js"; | ||
export { getEnvironmentLabels, getHostLabel, getThreadLabel, getPackageLabel, getLanguageLabel, getFrameworkLabel } from "./utils/labels.js"; | ||
//# sourceMappingURL=index.js.map |
@@ -6,11 +6,19 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } | ||
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 _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 _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"); } | ||
var _scopes = /*#__PURE__*/new WeakMap(); | ||
var _testResults = /*#__PURE__*/new WeakMap(); | ||
var _stepResults = /*#__PURE__*/new WeakMap(); | ||
var _fixturesResults = /*#__PURE__*/new WeakMap(); | ||
export class LifecycleState { | ||
constructor() { | ||
var _this = this; | ||
_defineProperty(this, "scopes", new Map()); | ||
_defineProperty(this, "testResults", new Map()); | ||
_defineProperty(this, "stepResults", new Map()); | ||
_defineProperty(this, "fixturesResults", new Map()); | ||
_defineProperty(this, "getScope", uuid => this.scopes.get(uuid)); | ||
_defineProperty(this, "getWrappedFixtureResult", uuid => this.fixturesResults.get(uuid)); | ||
_classPrivateFieldInitSpec(this, _scopes, new Map()); | ||
_classPrivateFieldInitSpec(this, _testResults, new Map()); | ||
_classPrivateFieldInitSpec(this, _stepResults, new Map()); | ||
_classPrivateFieldInitSpec(this, _fixturesResults, new Map()); | ||
_defineProperty(this, "getScope", uuid => _classPrivateFieldGet(_scopes, this).get(uuid)); | ||
_defineProperty(this, "getWrappedFixtureResult", uuid => _classPrivateFieldGet(_fixturesResults, this).get(uuid)); | ||
_defineProperty(this, "getFixtureResult", uuid => { | ||
@@ -20,4 +28,8 @@ var _this$getWrappedFixtu; | ||
}); | ||
_defineProperty(this, "getTestResult", uuid => this.testResults.get(uuid)); | ||
_defineProperty(this, "getStepResult", uuid => this.stepResults.get(uuid)); | ||
_defineProperty(this, "getWrappedTestResult", uuid => _classPrivateFieldGet(_testResults, this).get(uuid)); | ||
_defineProperty(this, "getTestResult", uuid => { | ||
var _this$getWrappedTestR; | ||
return (_this$getWrappedTestR = this.getWrappedTestResult(uuid)) === null || _this$getWrappedTestR === void 0 ? void 0 : _this$getWrappedTestR.value; | ||
}); | ||
_defineProperty(this, "getStepResult", uuid => _classPrivateFieldGet(_stepResults, this).get(uuid)); | ||
_defineProperty(this, "getExecutionItem", uuid => { | ||
@@ -28,27 +40,32 @@ var _ref, _this$getFixtureResul; | ||
// test results | ||
_defineProperty(this, "setTestResult", (uuid, result) => { | ||
this.testResults.set(uuid, result); | ||
_defineProperty(this, "setTestResult", function (uuid, result) { | ||
var scopeUuids = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : []; | ||
_classPrivateFieldGet(_testResults, _this).set(uuid, { | ||
value: result, | ||
scopeUuids | ||
}); | ||
}); | ||
_defineProperty(this, "deleteTestResult", uuid => { | ||
this.testResults.delete(uuid); | ||
_classPrivateFieldGet(_testResults, this).delete(uuid); | ||
}); | ||
// steps | ||
_defineProperty(this, "setStepResult", (uuid, result) => { | ||
this.stepResults.set(uuid, result); | ||
_classPrivateFieldGet(_stepResults, this).set(uuid, result); | ||
}); | ||
_defineProperty(this, "deleteStepResult", uuid => { | ||
this.stepResults.delete(uuid); | ||
_classPrivateFieldGet(_stepResults, this).delete(uuid); | ||
}); | ||
// fixtures | ||
_defineProperty(this, "setFixtureResult", (uuid, type, result) => { | ||
_defineProperty(this, "setFixtureResult", (scopeUuid, uuid, type, result) => { | ||
var wrappedResult = { | ||
uuid, | ||
type, | ||
value: result | ||
value: result, | ||
scopeUuid | ||
}; | ||
this.fixturesResults.set(uuid, wrappedResult); | ||
_classPrivateFieldGet(_fixturesResults, this).set(uuid, wrappedResult); | ||
return wrappedResult; | ||
}); | ||
_defineProperty(this, "deleteFixtureResult", uuid => { | ||
this.fixturesResults.delete(uuid); | ||
_classPrivateFieldGet(_fixturesResults, this).delete(uuid); | ||
}); | ||
@@ -59,2 +76,5 @@ // test scopes | ||
var scope = _objectSpread(_objectSpread({ | ||
labels: [], | ||
links: [], | ||
parameters: [], | ||
fixtures: [], | ||
@@ -65,7 +85,7 @@ tests: [] | ||
}); | ||
_this.scopes.set(uuid, scope); | ||
_classPrivateFieldGet(_scopes, _this).set(uuid, scope); | ||
return scope; | ||
}); | ||
_defineProperty(this, "deleteScope", uuid => { | ||
this.scopes.delete(uuid); | ||
_classPrivateFieldGet(_scopes, this).delete(uuid); | ||
}); | ||
@@ -72,0 +92,0 @@ } |
@@ -1,4 +0,1 @@ | ||
var _excluded = ["links", "labels", "parameters", "displayName"]; | ||
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; } | ||
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 ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } | ||
@@ -127,3 +124,3 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } | ||
var uuid = randomUuid(); | ||
var wrappedFixture = this.state.setFixtureResult(uuid, type, _objectSpread(_objectSpread({}, createFixtureResult()), {}, { | ||
var wrappedFixture = this.state.setFixtureResult(scopeUuid, uuid, type, _objectSpread(_objectSpread({}, createFixtureResult()), {}, { | ||
start: Date.now() | ||
@@ -171,3 +168,3 @@ }, fixtureResult)); | ||
}); | ||
_this.state.setTestResult(uuid, testResult); | ||
_this.state.setTestResult(uuid, testResult, scopeUuids); | ||
_this.notifier.afterTestResultStart(testResult); | ||
@@ -189,4 +186,4 @@ return uuid; | ||
var _testResult$testCaseI, _testResult$historyId; | ||
var testResult = this.state.getTestResult(uuid); | ||
if (!testResult) { | ||
var wrapped = this.state.getWrappedTestResult(uuid); | ||
if (!wrapped) { | ||
// eslint-disable-next-line no-console | ||
@@ -196,2 +193,3 @@ console.error("could not stop test result: no test with uuid ".concat(uuid, ") is found")); | ||
} | ||
var testResult = wrapped.value; | ||
this.notifier.beforeTestResultStop(testResult); | ||
@@ -203,6 +201,13 @@ (_testResult$testCaseI = testResult.testCaseId) !== null && _testResult$testCaseI !== void 0 ? _testResult$testCaseI : testResult.testCaseId = getTestResultTestCaseId(testResult); | ||
testResult.stop = startStop.stop; | ||
var scopeUuids = wrapped.scopeUuids; | ||
scopeUuids.forEach(scopeUuid => { | ||
var scope = this.state.getScope(scopeUuid); | ||
if (scope !== null && scope !== void 0 && scope.labels) { | ||
testResult.labels = [...testResult.labels, ...scope.labels]; | ||
} | ||
}); | ||
this.notifier.afterTestResultStop(testResult); | ||
}); | ||
_defineProperty(this, "writeTest", uuid => { | ||
var testResult = this.state.testResults.get(uuid); | ||
var testResult = this.state.getTestResult(uuid); | ||
if (!testResult) { | ||
@@ -354,18 +359,56 @@ // eslint-disable-next-line no-console | ||
// only display name could be set to fixture. | ||
var fixtureResult = this.state.getFixtureResult(rootUuid); | ||
var fixtureResult = this.state.getWrappedFixtureResult(rootUuid); | ||
var { | ||
links, | ||
labels, | ||
parameters, | ||
displayName, | ||
testCaseId, | ||
historyId, | ||
description, | ||
descriptionHtml | ||
} = message; | ||
if (fixtureResult) { | ||
this.updateFixture(rootUuid, result => { | ||
if (message.displayName) { | ||
result.name = message.displayName; | ||
if (displayName) { | ||
this.updateFixture(rootUuid, result => { | ||
result.name = displayName; | ||
}); | ||
} | ||
if (historyId) { | ||
// eslint-disable-next-line no-console | ||
console.error("historyId can't be changed within test fixtures"); | ||
} | ||
if (testCaseId) { | ||
// eslint-disable-next-line no-console | ||
console.error("testCaseId can't be changed within test fixtures"); | ||
} | ||
if (links || labels || parameters || description || descriptionHtml) { | ||
// in some frameworks, afterEach methods can be executed before test stop event, while | ||
// in others after. To remove the possible undetermined behaviour we only allow | ||
// using runtime metadata API in before hooks. | ||
if (fixtureResult.type === "after") { | ||
// eslint-disable-next-line no-console | ||
console.error("metadata messages isn't supported for after test fixtures"); | ||
return; | ||
} | ||
}); | ||
this.updateScope(fixtureResult.scopeUuid, scope => { | ||
if (links) { | ||
scope.links = [...scope.links, ...(this.linkConfig ? formatLinks(this.linkConfig, links) : links)]; | ||
} | ||
if (labels) { | ||
scope.labels = [...scope.labels, ...labels]; | ||
} | ||
if (parameters) { | ||
scope.parameters = [...scope.parameters, ...parameters]; | ||
} | ||
if (description) { | ||
scope.description = description; | ||
} | ||
if (descriptionHtml) { | ||
scope.descriptionHtml = descriptionHtml; | ||
} | ||
}); | ||
} | ||
return; | ||
} | ||
var { | ||
links, | ||
labels, | ||
parameters, | ||
displayName | ||
} = message, | ||
rest = _objectWithoutProperties(message, _excluded); | ||
this.updateTest(rootUuid, result => { | ||
@@ -384,3 +427,14 @@ if (links) { | ||
} | ||
Object.assign(result, rest); | ||
if (testCaseId) { | ||
result.testCaseId = testCaseId; | ||
} | ||
if (historyId) { | ||
result.historyId = historyId; | ||
} | ||
if (description) { | ||
result.description = description; | ||
} | ||
if (descriptionHtml) { | ||
result.descriptionHtml = descriptionHtml; | ||
} | ||
}); | ||
@@ -387,0 +441,0 @@ }); |
@@ -125,6 +125,2 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } | ||
}; | ||
export var getPackageLabelFromPath = filepath => ({ | ||
name: LabelName.PACKAGE, | ||
value: getRelativePath(filepath).split(path.sep).filter(v => v).join(".") | ||
}); | ||
export var deepClone = obj => JSON.parse(JSON.stringify(obj)); | ||
@@ -131,0 +127,0 @@ export var serialize = val => { |
import { hostname } from "node:os"; | ||
import path from "node:path"; | ||
import { env, pid } from "node:process"; | ||
import { isMainThread, threadId } from "node:worker_threads"; | ||
import { LabelName } from "../../../model.js"; | ||
import { getRelativePath } from "../utils.js"; | ||
var ENV_LABEL_PREFIX = "ALLURE_LABEL_"; | ||
@@ -39,2 +41,14 @@ export var getEnvironmentLabels = () => { | ||
}; | ||
export var getPackageLabel = filepath => ({ | ||
name: LabelName.PACKAGE, | ||
value: getRelativePath(filepath).split(path.sep).filter(v => v).join(".") | ||
}); | ||
export var getLanguageLabel = () => ({ | ||
name: LabelName.LANGUAGE, | ||
value: "javascript" | ||
}); | ||
export var getFrameworkLabel = framework => ({ | ||
name: LabelName.FRAMEWORK, | ||
value: framework | ||
}); | ||
//# sourceMappingURL=labels.js.map |
@@ -11,2 +11,3 @@ function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(e, r) { return new BabelRegExp(e, void 0, r); }; var e = RegExp.prototype, r = new WeakMap(); function BabelRegExp(e, t, p) { var o = RegExp(e, t); return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); } function buildGroups(e, t) { var p = r.get(t); return Object.keys(p).reduce(function (r, t) { var o = p[t]; if ("number" == typeof o) r[t] = e[o];else { for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; r[t] = e[o[i]]; } return r; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { var t = e.exec.call(this, r); if (t) { t.groups = buildGroups(t, this); var p = t.indices; p && (p.groups = buildGroups(p, this)); } return t; }, BabelRegExp.prototype[Symbol.replace] = function (t, p) { if ("string" == typeof p) { var o = r.get(this); return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)>/g, function (e, r) { var t = o[r]; return "$" + (Array.isArray(t) ? t.join("$") : t); })); } if ("function" == typeof p) { var i = this; return e[Symbol.replace].call(this, t, function () { var e = arguments; return "object" != typeof e[e.length - 1] && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); }); } return e[Symbol.replace].call(this, t, p); }, _wrapRegExp.apply(this, arguments); } | ||
* `jasmine` throws `ExpectationFailed` instance | ||
* `vitest` throws `Error` for extended assertions, so we look into stack | ||
*/ | ||
@@ -17,2 +18,3 @@ case /assert/gi.test(error.constructor.name): | ||
case /assert/gi.test(error.message): | ||
case error.stack && /@vitest\/expect/gi.test(error.stack): | ||
return Status.FAILED; | ||
@@ -19,0 +21,0 @@ default: |
@@ -12,2 +12,2 @@ export type * from "./types.js"; | ||
export { MessageReader } from "./writer/MessageReader.js"; | ||
export { getEnvironmentLabels, getHostLabel, getThreadLabel } from "./utils/labels.js"; | ||
export { getEnvironmentLabels, getHostLabel, getThreadLabel, getPackageLabel, getLanguageLabel, getFrameworkLabel, } from "./utils/labels.js"; |
import type { FixtureResult, StepResult, TestResult } from "../../model.js"; | ||
import type { FixtureType, FixtureWrapper, TestScope } from "./types.js"; | ||
import type { FixtureResultWrapper, FixtureType, TestResultWrapper, TestScope } from "./types.js"; | ||
export declare class LifecycleState { | ||
scopes: Map<string, TestScope>; | ||
testResults: Map<string, TestResult>; | ||
stepResults: Map<string, StepResult>; | ||
fixturesResults: Map<string, FixtureWrapper>; | ||
#private; | ||
getScope: (uuid: string) => TestScope | undefined; | ||
getWrappedFixtureResult: (uuid: string) => FixtureWrapper | undefined; | ||
getWrappedFixtureResult: (uuid: string) => FixtureResultWrapper | undefined; | ||
getFixtureResult: (uuid: string) => FixtureResult | undefined; | ||
getWrappedTestResult: (uuid: string) => TestResultWrapper | undefined; | ||
getTestResult: (uuid: string) => TestResult | undefined; | ||
getStepResult: (uuid: string) => StepResult | undefined; | ||
getExecutionItem: (uuid: string) => FixtureResult | TestResult | StepResult | undefined; | ||
setTestResult: (uuid: string, result: TestResult) => void; | ||
setTestResult: (uuid: string, result: TestResult, scopeUuids?: string[]) => void; | ||
deleteTestResult: (uuid: string) => void; | ||
setStepResult: (uuid: string, result: StepResult) => void; | ||
deleteStepResult: (uuid: string) => void; | ||
setFixtureResult: (uuid: string, type: FixtureType, result: FixtureResult) => FixtureWrapper; | ||
setFixtureResult: (scopeUuid: string, uuid: string, type: FixtureType, result: FixtureResult) => FixtureResultWrapper; | ||
deleteFixtureResult: (uuid: string) => void; | ||
@@ -20,0 +18,0 @@ setScope: (uuid: string, data?: Partial<TestScope>) => TestScope; |
/// <reference types="node" /> | ||
import type { FixtureResult, LinkType, StepResult, TestResult, TestResultContainer } from "../../model.js"; | ||
import type { FixtureResult, Label, Link, LinkType, Parameter, StepResult, TestResult, TestResultContainer } from "../../model.js"; | ||
import type { Category, EnvironmentInfo } from "../types.js"; | ||
@@ -46,9 +46,19 @@ export declare const ALLURE_METADATA_CONTENT_TYPE = "application/vnd.allure.metadata+json"; | ||
tests: string[]; | ||
fixtures: FixtureWrapper[]; | ||
fixtures: FixtureResultWrapper[]; | ||
labels: Label[]; | ||
links: Link[]; | ||
parameters: Parameter[]; | ||
description?: string; | ||
descriptionHtml?: string; | ||
}; | ||
export type FixtureType = "before" | "after"; | ||
export type FixtureWrapper = { | ||
export type FixtureResultWrapper = { | ||
uuid: string; | ||
value: FixtureResult; | ||
type: FixtureType; | ||
scopeUuid: string; | ||
}; | ||
export type TestResultWrapper = { | ||
value: TestResult; | ||
scopeUuids: string[]; | ||
}; |
@@ -17,3 +17,2 @@ /// <reference path="../../../../src/types/properties.d.ts" /> | ||
export declare const getRelativePath: (filepath: string) => string; | ||
export declare const getPackageLabelFromPath: (filepath: string) => Label; | ||
export declare const deepClone: <T>(obj: T) => T; | ||
@@ -20,0 +19,0 @@ export declare const serialize: (val: unknown) => string; |
@@ -5,1 +5,4 @@ import type { Label } from "../../../model.js"; | ||
export declare const getThreadLabel: (userProvidedThreadId?: string) => Label; | ||
export declare const getPackageLabel: (filepath: string) => Label; | ||
export declare const getLanguageLabel: () => Label; | ||
export declare const getFrameworkLabel: (framework: string) => Label; |
{ | ||
"name": "allure-js-commons", | ||
"version": "3.0.0-beta.10", | ||
"version": "3.0.0-beta.11", | ||
"description": "Allure JS Commons", | ||
@@ -91,3 +91,3 @@ "homepage": "https://allurereport.org/", | ||
"peerDependencies": { | ||
"allure-playwright": "3.0.0-beta.10" | ||
"allure-playwright": "3.0.0-beta.11" | ||
}, | ||
@@ -94,0 +94,0 @@ "peerDependenciesMeta": { |
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
748128
7342