Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Class constructor CucumberJSAllureFormatter cannot be invoked without 'new' #29

Closed
fescobar opened this issue Jul 18, 2019 · 7 comments

Comments

@fescobar
Copy link

fescobar commented Jul 18, 2019

It's working for typescript configuration but not for Java script config.
Same issue when you use versions:

    "cucumber": "5.1.0",
    "allure-cucumberjs": "2.0.0-beta.4",

Next Configuration

var CucumberJSAllureFormatter = require('allure-cucumberjs').CucumberJSAllureFormatter;
var AllureRuntime = require('allure-cucumberjs').AllureRuntime;

function Reporter(options) {
  CucumberJSAllureFormatter.call(this,
    options,
    new AllureRuntime({ resultsDir: "./out/allure-results" }),
    {});
}
Reporter.prototype = Object.create(CucumberJSAllureFormatter.prototype);
Reporter.prototype.constructor = Reporter;

exports.default = Reporter;
TypeError: Class constructor CucumberJSAllureFormatter cannot be invoked without 'new'
    at new Reporter (C:\Users\fescobar\Documents\git\cross-automation\allure-report.js:5:29)
    at Function.build (C:\Users\fescobar\Documents\git\cross-automation\node_modules\cucumber\lib\formatter\builder.js:49:12)
    at C:\Users\fescobar\Documents\git\cross-automation\node_modules\cucumber\lib\cli\index.js:121:35
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (C:\Users\fescobar\Documents\git\cross-automation\node_modules\cucumber\lib\cli\index.js:44:103)
    at _next (C:\Users\fescobar\Documents\git\cross-automation\node_modules\cucumber\lib\cli\index.js:46:194)

Related issue: korobochka/cucumberjs-allure2-reporter#4

@sseliverstov
Copy link
Collaborator

Did you update commons to beta.4?

@fescobar
Copy link
Author

fescobar commented Jul 18, 2019

@sseliverstov Do you mean this allure-js-commons? I've added that dependency:

    "allure-js-commons": "2.0.0-beta.4",

This showed

TypeError: Class constructor CucumberJSAllureFormatter cannot be invoked without 'new'
    at new Reporter (C:\Users\fescobar\Documents\git\cross-automation\allure-report.js:5:29)
    at Function.build (C:\Users\fescobar\Documents\git\cross-automation\node_modules\cucumber\lib\formatter\builder.js:86:14)
    at C:\Users\fescobar\Documents\git\cross-automation\node_modules\cucumber\lib\cli\index.js:139:38
    at Generator.next (<anonymous>)
    at Generator.tryCatcher (C:\Users\fescobar\Documents\git\cross-automation\node_modules\bluebird\js\release\util.js:16:23)
    at PromiseSpawn._promiseFulfilled (C:\Users\fescobar\Documents\git\cross-automation\node_modules\bluebird\js\release\generators.js:97:49)
    at Promise._settlePromise (C:\Users\fescobar\Documents\git\cross-automation\node_modules\bluebird\js\release\promise.js:579:26)
    at Promise._settlePromise0 (C:\Users\fescobar\Documents\git\cross-automation\node_modules\bluebird\js\release\promise.js:619:10)
    at Promise._settlePromises (C:\Users\fescobar\Documents\git\cross-automation\node_modules\bluebird\js\release\promise.js:699:18)
    at _drainQueueStep (C:\Users\fescobar\Documents\git\cross-automation\node_modules\bluebird\js\release\async.js:138:12)
    at _drainQueue (C:\Users\fescobar\Documents\git\cross-automation\node_modules\bluebird\js\release\async.js:131:9)
    at Async._drainQueues (C:\Users\fescobar\Documents\git\cross-automation\node_modules\bluebird\js\release\async.js:147:5)
    at Immediate.Async.drainQueues [as _onImmediate] (C:\Users\fescobar\Documents\git\cross-automation\node_modules\bluebird\js\release\async.js:17:14)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1

@fescobar
Copy link
Author

@sseliverstov will you release any no beta version for this component soon?. At least I could use it with typescript. Thank you.

@sethmcleod
Copy link

What you're seeing is most likely related to a bug in babel: babel/babel#7022

See this thread for some potential solutions based on your case: sequelize/sequelize#7840 (comment)

@lolpez
Copy link

lolpez commented Mar 6, 2020

Might be late but I managed to make it work with "cucumber": "^6.0.5". Hope it helps for future generations.
Here is my reporter.js

const CucumberJSAllureFormatter = require('allure-cucumberjs').CucumberJSAllureFormatter;
const AllureRuntime = require('allure-cucumberjs').AllureRuntime;

 /**
 * Allure Reporter class
 * @class
 */
  class Reporter extends CucumberJSAllureFormatter {
  /**
   * Create a allure report.
   * @param {Object} options - Allure options.
   */
    constructor(options) {
      super(
          options,
          new AllureRuntime({resultsDir:"./out/allure-results"}),
          {
            labels: {
              issue: [/@bug_(.*)/],
              epic: [/@feature:(.*)/],
            },
          },
      );
    }
  }

  exports.default = Reporter;

@aozolin
Copy link

aozolin commented Jun 4, 2020

I can still see the issue, it's preventing me to update to "cucumber": "^6.0.5"
Could you let me know when you expect to fix this please?

@sseliverstov
Copy link
Collaborator

this one right

var CucumberJSAllureFormatter = require("allure-cucumberjs").CucumberJSAllureFormatter;
var AllureRuntime = require("allure-cucumberjs").AllureRuntime;

function Reporter(options) {
  return new CucumberJSAllureFormatter(
    options,
    new AllureRuntime({ resultsDir: "./allure-results" }),
    {}
  );
}

Reporter.prototype = Object.create(CucumberJSAllureFormatter.prototype);
Reporter.prototype.constructor = Reporter;

exports.default = Reporter;

see README.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants