korobochka / cucumberjs-allure2-reporter

Allure 2 reporter for Cucumber.JS framework
MIT License
5 stars 5 forks source link

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

Open neerjain opened 5 years ago

neerjain commented 5 years ago

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 commented 5 years ago

@neerjain I need some additional information: Please provide:

neerjain commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

@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 commented 5 years ago

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

korobochka commented 5 years ago

@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 commented 5 years ago

@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 commented 5 years ago

@fescobar https://github.com/allure-framework/allure-js - main repot https://github.com/sseliverstov/allurejs-examples - some examples