How to use allure-js-commons - 10 common examples

To help you get started, we’ve selected a few allure-js-commons examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github allure-framework / allure-js / packages / allure-jasmine / src / JasmineAllureReporter.ts View on Github external
wrapped(function(done) {
          reporter.runningExecutable = fun();
          let ret;
          if (action.length > 0) { // function takes done callback
            ret = reporter.runningExecutable.wrap(() => new Promise((resolve, reject) => {
              const t: any = resolve;
              t.fail = reject;
              action(t);
            }))();
          } else {
            ret = reporter.runningExecutable.wrap(action)();
          }
          if (isPromise(ret)) {
            (ret as Promise).then(() => {
              reporter.runningExecutable = null;
              done();
            }).catch(e => {
              reporter.runningExecutable = null;
              done.fail(e);
            });
          } else {
            reporter.runningExecutable = null;
            done();
          }
        }, timeout);
      };
github allure-framework / allure-js / packages / allure-mocha / src / AllureReporter.ts View on Github external
public failTestCase(test: Mocha.Test, error: Error) {
    if (this.currentTest === null) {
      this.startCase(test);
    } else {
      const latestStatus = this.currentTest.status;
      // if test already has a failed state, we should not overwrite it
      if (latestStatus === Status.FAILED || latestStatus === Status.BROKEN) {
        return;
      }
    }
    const status = error.name === "AssertionError" ? Status.FAILED : Status.BROKEN;

    this.endTest(status, { message: error.message, trace: error.stack });
  }
github allure-framework / allure-js / packages / allure-mocha / src / AllureReporter.ts View on Github external
public failTestCase(test: Mocha.Test, error: Error) {
    if (this.currentTest === null) {
      this.startCase(test);
    } else {
      const latestStatus = this.currentTest.status;
      // if test already has a failed state, we should not overwrite it
      if (latestStatus === Status.FAILED || latestStatus === Status.BROKEN) {
        return;
      }
    }
    const status = error.name === "AssertionError" ? Status.FAILED : Status.BROKEN;

    this.endTest(status, { message: error.message, trace: error.stack });
  }
github allure-framework / allure-js / packages / allure-jasmine / src / JasmineAllureReporter.ts View on Github external
if (spec.status === SpecStatus.PENDING || spec.status === SpecStatus.DISABLED
      || spec.status === SpecStatus.EXCLUDED) {
      currentTest.status = Status.SKIPPED;
      currentTest.stage = Stage.PENDING;
      currentTest.detailsMessage = spec.pendingReason || "Suite disabled";
    }
    currentTest.stage = Stage.FINISHED;
    if (spec.status === SpecStatus.PASSED) {
      currentTest.status = Status.PASSED;
    }
    if (spec.status === SpecStatus.BROKEN) {
      currentTest.status = Status.BROKEN;
    }
    if (spec.status === SpecStatus.FAILED) {
      currentTest.status = Status.FAILED;
    }

    const exceptionInfo = this.findMessageAboutThrow(spec.failedExpectations)
      || this.findAnyError(spec.failedExpectations);
    if (exceptionInfo !== null) {
      currentTest.detailsMessage = exceptionInfo.message;
      currentTest.detailsTrace = exceptionInfo.stack;
    }

    currentTest.endTest();
    this.runningTest = null;

    this.currentGroup.endGroup(); // popping the test wrapper
    this.groupStack.pop();
  }
github allure-framework / allure-js / packages / allure-jasmine / src / JasmineAllureReporter.ts View on Github external
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);
      }
    }
  }
github allure-framework / allure-js / packages / allure-jasmine / src / JasmineAllureReporter.ts View on Github external
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);
      }
    }
  }
github allure-framework / allure-js / packages / allure-jasmine / src / JasmineAllureReporter.ts View on Github external
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);
      }
    }
  }
github allure-framework / allure-js / packages / allure-jasmine / src / JasmineAllureReporter.ts View on Github external
specStarted(spec: jasmine.CustomReporterResult): void {
    let currentGroup = this.getCurrentGroup();
    if (currentGroup === null) throw new Error("No active suite");

    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);
github allure-framework / allure-js / packages / allure-jasmine / src / JasmineAllureReporter.ts View on Github external
specDone(spec: jasmine.CustomReporterResult): void {
    const currentTest = this.runningTest;
    if (currentTest === null) throw new Error("specDone while no test is running");

    if (this.stepStack.length > 0) {
      console.error("Allure reporter issue: step stack is not empty on specDone");
      for (const step of this.stepStack.reverse()) {
        step.status = Status.BROKEN;
        step.stage = Stage.INTERRUPTED;
        step.detailsMessage = "Timeout";
        step.endStep();
      }
      this.stepStack = [];
    }

    if (spec.status === SpecStatus.PENDING || spec.status === SpecStatus.DISABLED
      || spec.status === SpecStatus.EXCLUDED) {
      currentTest.status = Status.SKIPPED;
      currentTest.stage = Stage.PENDING;
      currentTest.detailsMessage = spec.pendingReason || "Suite disabled";
    }
    currentTest.stage = Stage.FINISHED;
    if (spec.status === SpecStatus.PASSED) {
      currentTest.status = Status.PASSED;
github allure-framework / allure-js / packages / allure-jasmine / src / JasmineAllureReporter.ts View on Github external
if (currentTest === null) throw new Error("specDone while no test is running");

    if (this.stepStack.length > 0) {
      console.error("Allure reporter issue: step stack is not empty on specDone");
      for (const step of this.stepStack.reverse()) {
        step.status = Status.BROKEN;
        step.stage = Stage.INTERRUPTED;
        step.detailsMessage = "Timeout";
        step.endStep();
      }
      this.stepStack = [];
    }

    if (spec.status === SpecStatus.PENDING || spec.status === SpecStatus.DISABLED
      || spec.status === SpecStatus.EXCLUDED) {
      currentTest.status = Status.SKIPPED;
      currentTest.stage = Stage.PENDING;
      currentTest.detailsMessage = spec.pendingReason || "Suite disabled";
    }
    currentTest.stage = Stage.FINISHED;
    if (spec.status === SpecStatus.PASSED) {
      currentTest.status = Status.PASSED;
    }
    if (spec.status === SpecStatus.BROKEN) {
      currentTest.status = Status.BROKEN;
    }
    if (spec.status === SpecStatus.FAILED) {
      currentTest.status = Status.FAILED;
    }

    const exceptionInfo = this.findMessageAboutThrow(spec.failedExpectations)
      || this.findAnyError(spec.failedExpectations);