I am using the VSCode Cucumber plugin within a Typescript project that imports common shared steps from a Typescript npm module that is packaged as Javascript.
The plugin is able to successfully locate step definitions in Typescript from the local src code, but it fails to locate the shared Javascript steps from the dependency. This seems to be due to the regular expression for matching Javascript step definitions not working for Javascript files that were transpiled down from Typescript. Here's an example of what one of my steps looks like after it has been built into Javascript:
This seemed like it could be fixed by overriding TSX's defineStepDefinitionQueriesvalue in the Javascript implementation to look for Given|When|Then|Given)|When)|Then) however I get Invalid regular expression: Unmatched ')' errors when testing with it even if I try to escape the parentheses. I wasn't really sure what else to try in this case.
Any help would be greatly appreciated!
β What did you expect to see?
Expected the plugin to find the Javascript steps.
π¦ Which tool/library version are you using?
Cucumber VSCode plugin: v1.8.1
Node: v18.17.1
Typescript: v5.3.3
Cucumber: v9.6.0
π¬ How could we reproduce it?
Steps to reproduce the behavior:
Create a JS file with the following data:
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const cucumber_1 = require("@cucumber/cucumber");
(0, cucumber_1.Given)(/^I login$/, function () {
return __awaiter(this, void 0, void 0, function* () {
yield this.login();
});
});
Check the Cucumber Language Server output to see if it picks up the new step
π What did you see?
I am using the VSCode Cucumber plugin within a Typescript project that imports common shared steps from a Typescript npm module that is packaged as Javascript.
The plugin is able to successfully locate step definitions in Typescript from the local src code, but it fails to locate the shared Javascript steps from the dependency. This seems to be due to the regular expression for matching Javascript step definitions not working for Javascript files that were transpiled down from Typescript. Here's an example of what one of my steps looks like after it has been built into Javascript:
This seemed like it could be fixed by overriding TSX's
defineStepDefinitionQueries
value in the Javascript implementation to look forGiven|When|Then|Given)|When)|Then)
however I getInvalid regular expression: Unmatched ')'
errors when testing with it even if I try to escape the parentheses. I wasn't really sure what else to try in this case.Any help would be greatly appreciated!
β What did you expect to see?
Expected the plugin to find the Javascript steps.
π¦ Which tool/library version are you using?
π¬ How could we reproduce it?
Steps to reproduce the behavior:
π Any additional context?
This text was originally generated from a template, then edited by hand. You can modify the template here.