Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
currentGroup = currentGroup.startGroup("Test wrapper"); // needed to hold beforeEach/AfterEach
this.groupStack.push(currentGroup);
const name = spec.description;
const allureTest = currentGroup.startTest(name);
if (this.runningTest != null) throw new Error("Test is starting before other ended!");
this.runningTest = allureTest;
allureTest.fullName = spec.fullName;
allureTest.historyId = spec.fullName;
allureTest.stage = Stage.RUNNING;
// ignore wrapper, index + 1
if (this.groupStack.length > 1) {
allureTest.addLabel(LabelName.PARENT_SUITE, this.groupStack[0].name);
}
if (this.groupStack.length > 2) {
allureTest.addLabel(LabelName.SUITE, this.groupStack[1].name);
}
if (this.groupStack.length > 3) {
allureTest.addLabel(LabelName.SUB_SUITE, this.groupStack[2].name);
}
// TODO: if more depth add something to test name
for (const labels of this.labelStack) {
for (const label of labels) {
allureTest.addLabel(label.name, label.value);
}
}
}
public startCase(test: Mocha.Test) {
if (this.currentSuite === null) {
throw new Error("No active suite");
}
this.currentTest = this.currentSuite.startTest(test.title);
this.currentTest.fullName = test.title;
this.currentTest.historyId = createHash("md5")
.update(test.fullTitle())
.digest("hex");
this.currentTest.stage = Stage.RUNNING;
if (test.parent) {
const [parentSuite, suite, ...subSuites] = test.parent.titlePath();
if (parentSuite) {
this.currentTest.addLabel(LabelName.PARENT_SUITE, parentSuite);
}
if (suite) {
this.currentTest.addLabel(LabelName.SUITE, suite);
}
if (subSuites.length > 0) {
this.currentTest.addLabel(LabelName.SUB_SUITE, subSuites.join(" > "));
}
}
}