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

allure-mocha

Package Overview
Dependencies
Maintainers
3
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

allure-mocha - npm Package Compare versions

Comparing version 3.0.0-beta.4 to 3.0.0-beta.5

dist/cjs/types.js

41

dist/cjs/AllureMochaReporter.js

@@ -106,3 +106,4 @@ "use strict";

});
_defineProperty(this, "onSuiteEnd", () => {
_defineProperty(this, "onSuiteEnd", suite => {
this.writeTestScopes(suite);
var scopeUuid = this.scopesStack.pop();

@@ -124,3 +125,3 @@ if (scopeUuid) {

var scopeUuid = this.runtime.startScope();
this.scopesStack.push(scopeUuid);
(0, _utils.setTestScope)(test, scopeUuid);
this.currentTest = this.runtime.startTest({

@@ -132,3 +133,3 @@ name: (0, _utils.getAllureDisplayName)(test),

testCaseId: (0, _utils.getTestCaseId)(test)
}, this.scopesStack);
}, [...this.scopesStack, scopeUuid]);
});

@@ -181,12 +182,13 @@ _defineProperty(this, "onPassed", () => {

this.currentTest = undefined;
// finish dedicated scope for test
var scopeUuid = this.scopesStack.pop();
if (scopeUuid) {
this.runtime.writeScope(scopeUuid);
}
// We're writing the test's dedicated scope in onSuiteEnd instead of here
// because there might be afterEach hooks, which are reported after
// onTestEnd, not before.
}
});
_defineProperty(this, "onHookStart", hook => {
var _hook$originalTitle;
var scopeUuid = this.scopesStack.length > 0 ? this.scopesStack[this.scopesStack.length - 1] : undefined;
var _hook$ctx, _hook$originalTitle;
var [hookCategory, hookScope] = (0, _utils.getHookType)(hook);
var test = (_hook$ctx = hook.ctx) === null || _hook$ctx === void 0 ? void 0 : _hook$ctx.currentTest;
var scopeUuid = hookScope === "each" && test ? (0, _utils.getTestScope)(test) : this.getCurrentSuiteScope();
if (!scopeUuid) {

@@ -196,12 +198,6 @@ return;

var name = (_hook$originalTitle = hook.originalTitle) !== null && _hook$originalTitle !== void 0 ? _hook$originalTitle : "";
// eslint-disable-next-line @typescript-eslint/quotes
if (name.startsWith('"before')) {
this.currentHook = this.runtime.startFixture(scopeUuid, "before", {
if (hookCategory) {
this.currentHook = this.runtime.startFixture(scopeUuid, hookCategory, {
name
});
// eslint-disable-next-line @typescript-eslint/quotes
} else if (name.startsWith('"after')) {
this.currentHook = this.runtime.startFixture(scopeUuid, "after", {
name
});
}

@@ -228,2 +224,11 @@ });

});
_defineProperty(this, "writeTestScopes", suite => {
suite.tests.forEach(test => {
var testScopeUuid = (0, _utils.getTestScope)(test);
if (testScopeUuid) {
this.runtime.writeScope(testScopeUuid);
}
});
});
_defineProperty(this, "getCurrentSuiteScope", () => this.scopesStack.length > 0 ? this.scopesStack[this.scopesStack.length - 1] : undefined);
var _ref = _opts.reporterOptions || {},

@@ -230,0 +235,0 @@ {

@@ -6,3 +6,3 @@ "use strict";

});
exports.resolveParallelModeSetupFile = exports.isIncludedInTestRun = exports.getTestCaseId = exports.getSuitesOfMochaTest = exports.getInitialLabels = exports.getAllureMetaLabels = exports.getAllureId = exports.getAllureFullName = exports.getAllureDisplayName = exports.createTestPlanIndices = exports.applyTestPlan = void 0;
exports.setTestScope = exports.resolveParallelModeSetupFile = exports.isIncludedInTestRun = exports.getTestScope = exports.getTestCaseId = exports.getSuitesOfMochaTest = exports.getInitialLabels = exports.getHookType = exports.getAllureMetaLabels = exports.getAllureId = exports.getAllureFullName = exports.getAllureDisplayName = exports.createTestPlanIndices = exports.applyTestPlan = void 0;
var _nodePath = require("node:path");

@@ -66,2 +66,8 @@ var _nodeProcess = require("node:process");

exports.getAllureDisplayName = getAllureDisplayName;
var getTestScope = test => getAllureData(test).scope;
exports.getTestScope = getTestScope;
var setTestScope = (test, scope) => {
getAllureData(test).scope = scope;
};
exports.setTestScope = setTestScope;
var getSuitesOfMochaTest = test => test.titlePath().slice(0, -1);

@@ -99,2 +105,13 @@ exports.getSuitesOfMochaTest = getSuitesOfMochaTest;

exports.applyTestPlan = applyTestPlan;
var hookTypeRegexp = /^"(before|after) (all|each)"/;
var getHookType = hook => {
if (hook.originalTitle) {
var match = hookTypeRegexp.exec(hook.originalTitle);
if (match) {
return [match[1], match[2]];
}
}
return [];
};
exports.getHookType = getHookType;
//# sourceMappingURL=utils.js.map

@@ -16,3 +16,3 @@ var _excluded = ["resultsDir", "writer"];

import { setLegacyApiRuntime } from "./legacyUtils.js";
import { applyTestPlan, createTestPlanIndices, getAllureDisplayName, getAllureFullName, getAllureMetaLabels, getInitialLabels, getSuitesOfMochaTest, getTestCaseId, isIncludedInTestRun, resolveParallelModeSetupFile } from "./utils.js";
import { applyTestPlan, createTestPlanIndices, getAllureDisplayName, getAllureFullName, getAllureMetaLabels, getHookType, getInitialLabels, getSuitesOfMochaTest, getTestCaseId, getTestScope, isIncludedInTestRun, resolveParallelModeSetupFile, setTestScope } from "./utils.js";
var {

@@ -99,3 +99,4 @@ EVENT_SUITE_BEGIN,

});
_defineProperty(this, "onSuiteEnd", () => {
_defineProperty(this, "onSuiteEnd", suite => {
this.writeTestScopes(suite);
var scopeUuid = this.scopesStack.pop();

@@ -117,3 +118,3 @@ if (scopeUuid) {

var scopeUuid = this.runtime.startScope();
this.scopesStack.push(scopeUuid);
setTestScope(test, scopeUuid);
this.currentTest = this.runtime.startTest({

@@ -125,3 +126,3 @@ name: getAllureDisplayName(test),

testCaseId: getTestCaseId(test)
}, this.scopesStack);
}, [...this.scopesStack, scopeUuid]);
});

@@ -174,12 +175,13 @@ _defineProperty(this, "onPassed", () => {

this.currentTest = undefined;
// finish dedicated scope for test
var scopeUuid = this.scopesStack.pop();
if (scopeUuid) {
this.runtime.writeScope(scopeUuid);
}
// We're writing the test's dedicated scope in onSuiteEnd instead of here
// because there might be afterEach hooks, which are reported after
// onTestEnd, not before.
}
});
_defineProperty(this, "onHookStart", hook => {
var _hook$originalTitle;
var scopeUuid = this.scopesStack.length > 0 ? this.scopesStack[this.scopesStack.length - 1] : undefined;
var _hook$ctx, _hook$originalTitle;
var [hookCategory, hookScope] = getHookType(hook);
var test = (_hook$ctx = hook.ctx) === null || _hook$ctx === void 0 ? void 0 : _hook$ctx.currentTest;
var scopeUuid = hookScope === "each" && test ? getTestScope(test) : this.getCurrentSuiteScope();
if (!scopeUuid) {

@@ -189,12 +191,6 @@ return;

var name = (_hook$originalTitle = hook.originalTitle) !== null && _hook$originalTitle !== void 0 ? _hook$originalTitle : "";
// eslint-disable-next-line @typescript-eslint/quotes
if (name.startsWith('"before')) {
this.currentHook = this.runtime.startFixture(scopeUuid, "before", {
if (hookCategory) {
this.currentHook = this.runtime.startFixture(scopeUuid, hookCategory, {
name
});
// eslint-disable-next-line @typescript-eslint/quotes
} else if (name.startsWith('"after')) {
this.currentHook = this.runtime.startFixture(scopeUuid, "after", {
name
});
}

@@ -221,2 +217,11 @@ });

});
_defineProperty(this, "writeTestScopes", suite => {
suite.tests.forEach(test => {
var testScopeUuid = getTestScope(test);
if (testScopeUuid) {
this.runtime.writeScope(testScopeUuid);
}
});
});
_defineProperty(this, "getCurrentSuiteScope", () => this.scopesStack.length > 0 ? this.scopesStack[this.scopesStack.length - 1] : undefined);
var _ref = _opts.reporterOptions || {},

@@ -223,0 +228,0 @@ {

@@ -53,2 +53,6 @@ import { dirname, extname, join } from "node:path";

export var getAllureDisplayName = test => getAllureData(test).displayName;
export var getTestScope = test => getAllureData(test).scope;
export var setTestScope = (test, scope) => {
getAllureData(test).scope = scope;
};
export var getSuitesOfMochaTest = test => test.titlePath().slice(0, -1);

@@ -81,2 +85,12 @@ export var resolveParallelModeSetupFile = () => join(dirname(filename), "setupAllureMochaParallel".concat(extname(filename)));

};
var hookTypeRegexp = /^"(before|after) (all|each)"/;
export var getHookType = hook => {
if (hook.originalTitle) {
var match = hookTypeRegexp.exec(hook.originalTitle);
if (match) {
return [match[1], match[2]];
}
}
return [];
};
//# sourceMappingURL=utils.js.map

@@ -37,2 +37,4 @@ /// <reference types="node" />

private onHookEnd;
private writeTestScopes;
private getCurrentSuiteScope;
}
import type * as Mocha from "mocha";
import type { Label } from "allure-js-commons";
type AllureMochaTestData = {
isIncludedInTestRun: boolean;
fullName: string;
labels: readonly Label[];
displayName: string;
};
export type TestPlanIndices = {
fullNameIndex: ReadonlySet<string>;
idIndex: ReadonlySet<string>;
};
import type { AllureMochaTestData, HookType, TestPlanIndices } from "./types.js";
export declare const createTestPlanIndices: () => TestPlanIndices | undefined;

@@ -19,2 +10,4 @@ export declare const getAllureFullName: (test: Mocha.Test) => string;

export declare const getAllureDisplayName: (test: Mocha.Test) => string;
export declare const getTestScope: (test: Mocha.Test) => string | undefined;
export declare const setTestScope: (test: Mocha.Test, scope: string) => void;
export declare const getSuitesOfMochaTest: (test: Mocha.Test) => string[];

@@ -25,2 +18,2 @@ export declare const resolveParallelModeSetupFile: () => string;

export declare const applyTestPlan: (ids: ReadonlySet<string>, selectors: ReadonlySet<string>, rootSuite: Mocha.Suite) => void;
export {};
export declare const getHookType: (hook: Mocha.Hook) => HookType;
{
"name": "allure-mocha",
"version": "3.0.0-beta.4",
"version": "3.0.0-beta.5",
"description": "Allure Mocha integration",

@@ -58,3 +58,3 @@ "keywords": [

"dependencies": {
"allure-js-commons": "3.0.0-beta.4"
"allure-js-commons": "3.0.0-beta.5"
},

@@ -71,7 +71,7 @@ "devDependencies": {

"@types/mocha": "^10.0.1",
"@types/node": "^20.6.3",
"@types/node": "^20.14.2",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"allure-commandline": "^2.29.0",
"allure-vitest": "3.0.0-beta.4",
"allure-vitest": "3.0.0-beta.5",
"babel-plugin-add-module-exports": "^1.0.4",

@@ -94,3 +94,3 @@ "babel-plugin-transform-import-meta": "^2.2.1",

"source-map-support": "^0.5.21",
"ts-node": "^10.9.1",
"ts-node": "^10.9.2",
"tslib": "^2.6.2",

@@ -97,0 +97,0 @@ "typescript": "^5.2.2",

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