badeball / cypress-cucumber-preprocessor

Run cucumber/gherkin-syntaxed specs with Cypress
MIT License
1.32k stars 149 forks source link

Can't find my stepDefinitions #310

Closed smvilar closed 2 years ago

smvilar commented 4 years ago

Since the 2.0.1 version I can't run my tests anymore. I read the changelog and I added the required config to my package.json:

{
  "nonGlobalStepDefinitions": true,
+  "stepDefinitions": "cypress/e2e",
+  "commonPath": "cypress/e2e/common"
}

(instead of being in cypress/integration, my tests are in cypress/e2e)

This doesn't work. Am I reading something wrong from the documentation?

lgandecki commented 4 years ago

This won't be enough for me to help. Please show the error message. Are you on Windows? Is everything working fine with the last 1.* Version? Please stick with that meanwhile. Do you use Vue? Any chance for a simple reproduction?

smvilar commented 4 years ago

Sorry! I've been tinkering a bit more and the issue was defining the commonPath value. I removed that setting and everything worked again. 😄

To reproduce the issue, just go to the example repo you have and make the following changes:

I'm not sure if this is an issue in the documentation or if it's not an issue at all. Feel free to close it.

pravynandas commented 4 years ago

I agree with @smvilar .

The comment from v2.0.1 related commit kind of broke the setting. Had to remove commonPath and also stepDefinitions setting is not required to work it with 2.0.1

BREAKING CHANGE: You need to configure the stepDefinitions if you use the nonGlobalStepDefinitions option.

It is indeed working fine with below usual setting in package.json

"cypress-cucumber-preprocessor": { "nonGlobalStepDefinitions": true, }

lgandecki commented 4 years ago

I guess the message should say "if things don't work you need to configure the stepDefinitions", but, also, I'm not sure how setting the stepDefinitions to a correct path could break anything? My thinking was that it's better if anyone just explicitly set the path to the stepDefinitions, instead of relying on defaults from Cypress (that we don't control)

jvanoostveen commented 4 years ago

I'm having issues on Windows with 2.0.1.. it shows this error:

Error: load and loadSync must pass a non-empty string
    at Explorer.validateFilePath (C:\Anta\generator\node_modules\cosmiconfig\dist\createExplorer.js:269:13)
    at C:\Anta\generator\node_modules\cosmiconfig\dist\createExplorer.js:275:12

It seems to give the same error no matter the config I throw at it...

  "cypress-cucumber-preprocessor": {
    "nonGlobalStepDefinitions": true,
    "stepDefinitions": "cypress/integration",
    "commonPath": "cypress/integration/common"
  }
pravynandas commented 4 years ago

@jvanoostveen above configuration looks ok. But since cosmic config can throw error from any other parts of the packages.json file, please review entire file and not just this part.

SokolovAlex commented 3 years ago

Guys, how it must be working if in your code you execute

const loader = cosmiconfig("cypress-cucumber-preprocessor"; const loaded = explorer.load(); https://github.com/TheBrainFamily/cypress-cucumber-preprocessor/blob/master/lib/getConfig.js#L13

but its not by documentation of cosmiconfig https://github.com/davidtheclark/cosmiconfig#explorerload

you need to pass here file name like const result = explorerSync.load(loadPath);

and have a trouble if (!filepath) { throw new Error('load must pass a non-empty string'); } https://github.com/davidtheclark/cosmiconfig/blob/main/src/ExplorerBase.ts#L130

lgandecki commented 3 years ago

It's a singleton pattern, we load the cosmiconfig once:

if (!explorer) {
    explorer = cosmiconfig("cypress-cucumber-preprocessor", {
      sync: true,
      rcExtensions: true,
    });
  }

the name of the package is used to look for the configuration, on subsequent calls to this function it just reuses the already loaded configuration

badeball commented 2 years ago

Due to personal reasons, the previous maintainers of this package are stepping down and handing the reigns over to me, a long-time contributor to the project and a user of it myself. This is a responsibility I'm very excited about. Furthermore, I'd like to thank @lgandecki ++ for all the work that they've done so far.

Read more about the transfer of ownership here.

The repository has however moved and all outstanding issues are being closed. This is not a reflection of the perceived importance of your reported issue. However, if after upgrading to the new version, you still find there to be an issue, feel free to open up another ticket or comment below. Please make sure to read CONTRIBUTING.md before doing so.