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

Test runner says steps are undefined when official Cubumer extension can navigate between steps and features. #1

Closed
jvdwyer opened this issue Mar 31, 2023 · 6 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@jvdwyer
Copy link

jvdwyer commented Mar 31, 2023

Hello. When trying this extension and running/debugging scenarios the test running says "Undefined. Implement with the following snippet". But when I run using cucumber-js script cucumber is able to link the feature file with step file and run the tests. Here is my cucumber.js file:

const dotenv = require('dotenv');

dotenv.config({override: false});

let options = [
'--require-module ts-node/register',
'--require ./srs-vp/System-Requirement-Specifications/Functional-Requirements/steps/*steps.ts',
'--format progress',
].join(' ');

let run_features = [
'./srs-vp/System-Requirement-Specifications/Functional-Requirements/features/*.feature',
options,
].join(' ');

module.exports = {
test_runner: run_features
};

Here is my settings.json:

{
"cucumberautocomplete.strictGherkinCompletion": true,
"cucumberautocomplete.steps": [
"./doc/srs-vp/System-Requirement-Specifications/Functional-Requirements/steps/.ts"
],
"cucumberautocomplete.syncfeatures": "./doc/srs-vp/System-Requirement-Specifications/Functional-Requirements/features/
.feature",
}

@Balrog994
Copy link
Owner

Hi, I'll look into it in the weekend 👍

@Balrog994
Copy link
Owner

Balrog994 commented Apr 1, 2023

Your main issue is due to a missing feature of this extension. The extensions launches tests with the default profile, your configuration file exports a profile named test_runner.

To solve this problem you have to change your cucumber.js config as follows (until I add the feature)

module.exports = {
-  test_runner: run_features
+  default: run_features,
};

This however brings up a new problem that's actually mentioned in the following issue cucumber/cucumber-js#2253 on the cucumber-js repository.

I think I have a workaround until cucumber-js implements better support for cli arguments.
You can change your cucumber.js file as follows:

const dotenv = require("dotenv");

dotenv.config({ override: false });

let options = [
  '--require-module ts-node/register',
  '--require ./srs-vp/System-Requirement-Specifications/Functional-Requirements/steps/*steps.ts',
  '--format progress',
].join(" ");

- let run_features = ['./srs-vp/System-Requirement-Specifications/Functional-Requirements/features/*.feature', options].join(" ");
+ //let run_features = ['./srs-vp/System-Requirement-Specifications/Functional-Requirements/features/*.feature', options].join(" ");

module.exports = {
-  default: run_features,
+  default: options,
};

This allows the extension to launch the tests correctly.

Hope this helps 😉

@Balrog994 Balrog994 added bug Something isn't working enhancement New feature or request labels Apr 1, 2023
@jvdwyer
Copy link
Author

jvdwyer commented Apr 3, 2023

Thanks for the response. I made changes (below) to cucumber-js but am still seeing the same behavior. When I run using cucumber-js script cucumber is able to link the feature file with step file and run the tests but cucumber-test-runner reports that the steps are undefined.

cucumber-js:

const dotenv = require('dotenv');

dotenv.config({ override: false });

let options = [
'--require-module ts-node/register',
'./srs-vp/System-Requirement-Specifications/Functional-Requirements/features/*.feature',
'--require ./srs-vp/System-Requirement-Specifications/Functional-Requirements/steps/*steps.ts',
'--format html:cucumber-report/cucumber-report.html',
'--publish-quiet'
].join(' ');

module.exports = {
default: options,
};

@Balrog994
Copy link
Owner

Hi,

I guess your problem is the following line:

'./srs-vp/System-Requirement-Specifications/Functional-Requirements/features/*.feature',

If you keep that line in the configuration, the extension will not work properly due to the problem mentioned before.
You need to remove the path to your *.feature files, the extension will discover the files on its own and launch the proper test.

If you need both the configurations, you can try to define 2 profiles, the default one for the extension and another one to launch the tests from the CLI.

@jvdwyer
Copy link
Author

jvdwyer commented Apr 4, 2023

Hello again. I took your suggestion and created multiple profiles but the behavior is the exact same:


dotenv.config({ override: false });

const common = {
    requireModule: ['ts-node/register'],
    require: ['./srs-vp/System-Requirement-Specifications/Functional-Requirements/steps/*steps.ts'],
    publishQuiet: true
}

const paths = [
    './srs-vp/System-Requirement-Specifications/Functional-Requirements/features/*.feature'
]

module.exports = {
    default: {
        ...common,
        format: ['html:cucumber-report/cucumber-report.html', 'progress'],
    },
    cli: {
        ...common,
        format: ['html:cucumber-report/cucumber-report.html'],
        paths,
    }
};

@Balrog994
Copy link
Owner

Seems like I can't reproduce your problem, just for debug purposes that's what the extension executes to run tests:

node ./node_modules/@cucumber/cucumber/bin/cucumber.js <full-path-to-feature-file>:<line-of-the-selected-test> [...<full-path-to-feature-file>:<line-of-the-selected-test>] --format message

The command is executed from the working folder open in VSCode.
You may try to run the same line from your terminal and check if you get the same behavior.

I tried your new configuration in my test project and, aside from manually creating the cucumber-report folder, I had no problems, the extension ran the tests correctly.

I would be great if you could publish a minimal project that exposes this behavior 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants