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 Formatter cannot be invoked without 'new' #4

Open
neerjain opened this issue Jan 25, 2019 · 8 comments
Open

Comments

@neerjain
Copy link

Hi,

I have written the code mentioned in READme in both syntax ES6 and non ES6 but it is throwing below error:

TypeError: Class constructor Formatter cannot be invoked without 'new'

@korobochka
Copy link
Owner

korobochka commented Jan 25, 2019

@neerjain I need some additional information:
Please provide:

  • full source code for your Reporter file
  • full stack trace
  • Node version and flags you are running this under; also versions of transpilers (like babel) if you use any

@neerjain
Copy link
Author

Please find below teh details:

  1. Source code of Reporter.js file

`const CucumberJSAllureFormatter = require("cucumberjs-allure2-reporter").CucumberJSAllureFormatter;
const AllureRuntime = require("cucumberjs-allure2-reporter").AllureRuntime;

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

module.exports = Reporter;`

Stack Trace:

[14:21:54] E/launcher - Error: TypeError: Class constructor Formatter cannot be invoked without 'new'
at new CucumberJSAllureFormatter (D:\Protractor Cucumber\withpageWiseObjectRepository\node_modules\cucumberjs-allure2-reporter\src\CucumberJSAllureReporter.ts:54:3)
at new Reporter (D:/Protractor Cucumber/withpageWiseObjectRepository/util/AllureReporter.js:6:9)
at Function.build (D:\Protractor Cucumber\withpageWiseObjectRepository\node_modules\cucumber\lib\formatter\builder.js:49:12)
at D:\Protractor Cucumber\withpageWiseObjectRepository\node_modules\cucumber\lib\cli\index.js:121:35
at Generator.next ()
at asyncGeneratorStep (D:\Protractor Cucumber\withpageWiseObjectRepository\node_modules\cucumber\lib\cli\index.js:44:103)
at _next (D:\Protractor Cucumber\withpageWiseObjectRepository\node_modules\cucumber\lib\cli\index.js:46:194)
at D:\Protractor Cucumber\withpageWiseObjectRepository\node_modules\cucumber\lib\cli\index.js:46:364
at new Promise ()
at D:\Protractor Cucumber\withpageWiseObjectRepository\node_modules\cucumber\lib\cli\index.js:46:97
at D:\Protractor Cucumber\withpageWiseObjectRepository\node_modules\cucumber\lib\cli\index.js:125:23
at tryCatcher (D:\Protractor Cucumber\withpageWiseObjectRepository\node_modules\bluebird\js\release\util.js:16:23)
at MappingPromiseArray._promiseFulfilled (D:\Protractor Cucumber\withpageWiseObjectRepository\node_modules\bluebird\js\release\map.js:61:38)
at MappingPromiseArray.PromiseArray._iterate (D:\Protractor Cucumber\withpageWiseObjectRepository\node_modules\bluebird\js\release\promise_array.js:114:31)
at MappingPromiseArray.init (D:\Protractor Cucumber\withpageWiseObjectRepository\node_modules\bluebird\js\release\promise_array.js:78:10)
at MappingPromiseArray._asyncInit (D:\Protractor Cucumber\withpageWiseObjectRepository\node_modules\bluebird\js\release\map.js:30:10)

Node version: 8.11.3

I am running this through protractor conf.js file

cucumberOpts: {
strict: true,
format: ['node_modules/cucumber-pretty', 'json:./reports/json/cucumber_report.json', './util/AllureReporter.js'],
require: ["../testSpecifications/.js", "../util/.js"],

},

@korobochka
Copy link
Owner

@neerjain After some experiments, it looks like there were some incompatible changes in Cucumber version 5.
Latest supported version is "cucumber": "^4.2.1" for now.
I've tested that your example works well after downgrade.
I will try to work on the support for cucumber 5, but can not promise any timeline.

@sseliverstov
Copy link

sseliverstov commented May 18, 2019

@neerjain possibly you need to fix tsconfig.json, here working example https://github.com/sseliverstov/allurejs-examples/tree/master/cucumber-js5-allure2. Also we copy @korobochka 's code to our organization https://github.com/allure-framework/allure-js.

@fescobar
Copy link

@korobochka can you release a new version of cucumberjs-allure2-reporter with the fix?
Thank you so much

@korobochka
Copy link
Owner

@fescobar : I am not maintaining this project anymore (everything moved to main Allure repo, but that version is not released yet).
If you can test tsconfig changes and submit PR here -- I'll release the hotfix.

@fescobar
Copy link

@korobochka I'll try to create the PR. What main Allure repo? can you share the link?
@sseliverstov can you give access to the example? or upload it here, please?

@sseliverstov
Copy link

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

4 participants