How to use the allure-js-commons.isPromise function in allure-js-commons

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 / MochaAllureInterface.ts View on Github external
public step(name: string, body: (step: StepInterface) => any): any {
    const wrappedStep = this.startStep(name);
    let result;
    try {
      result = wrappedStep.run(body);
    } catch (err) {
      wrappedStep.endStep();
      throw err;
    }
    if (isPromise(result)) {
      const promise = result as Promise;
      return promise
        .then(a => {
          wrappedStep.endStep();
          return a;
        })
        .catch(e => {
          wrappedStep.endStep();
          throw e;
        });
    }
    wrappedStep.endStep();
    return result;
  }
github allure-framework / allure-js / packages / allure-jasmine / src / JasmineAllureReporter.ts View on Github external
step(name: string, body: (step: StepInterface) => any): any {
    const wrappedStep = this.startStep(name);
    let result;
    try {
      result = wrappedStep.run(body);
    } catch (err) {
      wrappedStep.endStep();
      throw err;
    }
    if (isPromise(result)) {
      const promise = result as Promise;
      return promise.then(a => {
        wrappedStep.endStep();
        return a;
      }).catch(e => {
        wrappedStep.endStep();
        throw e;
      });
    } else {
      wrappedStep.endStep();
      return result;
    }
  }
github allure-framework / allure-js / packages / allure-cucumberjs / src / CucumberAllureInterface.ts View on Github external
step(name: string, body: (step: StepInterface) => any): any {
    const wrappedStep = this.startStep(name);
    let result;
    try {
      result = wrappedStep.run(body);
    } catch (err) {
      wrappedStep.endStep();
      throw err;
    }
    if (isPromise(result)) {
      const promise = result as Promise;
      return promise.then(a => {
        wrappedStep.endStep();
        return a;
      }).catch(e => {
        wrappedStep.endStep();
        throw e;
      });
    } else {
      wrappedStep.endStep();
      return result;
    }
  }