Description
Describe the bug
I unable to run cucumber.js file after migrating to the cucumber 10.8 version.It is showing below error.
Error: Failed to import formatter ./src/helper/report/allureReport.ts
at importCode (/Users/test/Documents/Workspace/purpleportalautomation/node_modules/@cucumber/cucumber/src/formatter/import_code.ts:14:11)
at async resolveImplementation (/Users/test/Documents/Workspace/purpleportalautomation/node_modules/@cucumber/cucumber/src/formatter/resolve_implementation.ts:13:22)
at async initializeFormatter (/Users/test/Documents/Workspace/purpleportalautomation/node_modules/@cucumber/cucumber/src/api/formatters.ts:51:28)
at async initializeFormatters (/Users/test/Documents/Workspace/purpleportalautomation/node_modules/@cucumber/cucumber/src/api/formatters.ts:86:5)
at async runCucumber (/Users/test/Documents/Workspace/purpleportalautomation/node_modules/@cucumber/cucumber/src/api/run_cucumber.ts:93:29)
at async Cli.run (/Users/test/Documents/Workspace/purpleportalautomation/node_modules/@cucumber/cucumber/src/cli/index.ts:79:25)
at async Object.run [as default] (/Users/test/Documents/Workspace/purpleportalautomation/node_modules/@cucumber/cucumber/src/cli/run.ts:32:14) {
[cause]: TypeError: Unknown file extension ".ts" for /Users/test/Documents/Workspace/purpleportalautomation/src/helper/report/allureReport.ts
Note:
It is not allowing to import below
import { CucumberAllureWorld } from 'allure-cucumberjs'
To Reproduce
Steps to reproduce the behavior:
Migrate cucumber version to latest 10.8
Run the following command npx cucumber-js test --tags '@smoke'
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: mac sonoma 14.5
- Browser chrome
//allureReport.ts
/* eslint-disable @typescript-eslint/no-explicit-any */
import { AllureRuntime, CucumberJSAllureFormatter } from 'allure-cucumberjs'
function Reporter(options: any) {
return new CucumberJSAllureFormatter(
options,
new AllureRuntime({ resultsDir: 'reports/allure-results' }),
{
labels: [
{
name: 'epic',
pattern: [/@feature:(.)/],
},
{
name: 'severity',
pattern: [/@Severity:(.)/],
},
],
links: [
{
type: 'issue',
pattern: [/@issue=(.)/],
urlTemplate: 'http://localhost:8080/issue/%s',
},
{
type: 'tms',
pattern: [/@tms=(.)/],
urlTemplate: 'http://localhost:8080/tms/%s',
},
],
}
)
}
Reporter.prototype = Object.create(CucumberJSAllureFormatter.prototype)
Reporter.prototype.constructor = Reporter
exports.default = Reporter
cucumber.json
{
"default": {
"paths": ["src/test/features"],
"require": ["src/test/stepDefinitions/*.ts", "src/hooks/hooks.ts"],
"requireModule": ["ts-node/register"],
"publishQuiet": true,
"format": [
"progress-bar",
"./src/helper/report/allureReport.ts:./output.txt",
"html:reports/cucumberReport/cucumber-report.html",
"json:reports/cucumberReport/cucumber-report.json"
],
"parallel": 1
}
}
package.json
