How can I access constructor variables inside static methods in a class when the property is declared as 'static' with 'this' and not accessible?
export class Reporter {
constructor() {
this.jsonReports = path.join(process.cwd(), "/reports/json")
this.cucumberReporterOptions = {
jsonFile: targetJson,
output: htmlReports + "/cucumber_reporter.html",
reportSuiteAsScenarios: true,
theme: "bootstrap",
}
}
static createHTMLReport() {
try {
reporter.generate(this.cucumberReporterOptions);
} catch (err) {
}
}
}
Updated:
In my 'reporter.js' file, I followed the suggestion by "@CodingIntrigue" and accessed the method using Reporter.createHTMLReport() in my config file. It worked well, but I'm unsure if this approach is best practice.
const jsonReports = path.join(process.cwd(), "/reports/json")
const cucumberReporterOptions = {
jsonFile: targetJson,
output: htmlReports + "/cucumber_reporter.html",
reportSuiteAsScenarios: true,
theme: "bootstrap",
}
export class Reporter {
static createHTMLReport() {
try {
reporter.generate(cucumberReporterOptions);
} catch (err) {
}
}
}