badeball / cypress-cucumber-preprocessor

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

Error returned when running scenarios with cypress-tags #546

Closed raisapirgari closed 3 years ago

raisapirgari commented 3 years ago

Current behavior

Error returned when running scenarios with cypress-tags:

> cypress-tags run --config baseUrl=https://xxx -e TAGS=@api

internal/fs/utils.js:269
    throw err;
    ^

Error: EISDIR: illegal operation on a directory, read
    at Object.readSync (fs.js:568:3)
    at tryReadSync (fs.js:353:20)
    at D:\creditplace2\node_modules\cypress-cucumber-preprocessor\cypress-tags.js:45:22
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (D:\creditplace2\node_modules\cypress-cucumber-preprocessor\cypress-tags.js:44:7)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14) {
  errno: -4068,
  syscall: 'read',
  code: 'EISDIR'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! aut@1.0.0 comandLine: `cypress-tags run --config baseUrl=https://platform.staging.creditplacedevelopment.com/admin -e TAGS=@api`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the aut@1.0.0 comandLine script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\RaisaPC\AppData\Roaming\npm-cache\_logs\2021-04-14T11_03_25_440Z-debug.log

Desired behavior

Till few days ago I was able to run E2E client side scenarios with above scripts, but after enriching tests with more API tests, cypress-tags is not working at all. At the same time I am able to run scenarios in browser runner and this means that scenarios are 'heathy and correct' and I should be able to run scenarios also from command line with tag selector

Test code to reproduce

@api
Feature: Upload invoice scenarios

  Scenario Outline: Basic upload invoice
    Given a "admin" token was generated
    When invoice uploaded with following data
      | supplierId   | uploadedBy   | amount   | redemptionDate   | invoiceIssueDate   | serviceDeliveryDate   | debtorId   |
      | <supplierId> | <uploadedBy> | <amount> | <redemptionDate> | <invoiceIssueDate> | <serviceDeliveryDate> | <debtorId> |
    Then invoice created with following data
      | supplierId   | uploadedBy   | amount   | redemptionDate   | invoiceIssueDate   | serviceDeliveryDate   | debtorId  | status   |
      | <supplierId> | <uploadedBy> | <amount> | <redemptionDate> | <invoiceIssueDate> | <serviceDeliveryDate> | <debtorId | <status> |

    Examples:
      | supplier | uploaded | amount | redemptionDate | invoiceIssueDate | serviceDeliveryDate | debtor | status |
      | xxx         |  xxx          | 1000      | 06/30/2021        | 04/06/2021          | 04/06/2021              | xxx       | xxx|

and steps for above scenarios : 

    Given("a {string} token was generated", role => {
    })
    When("invoice uploaded with following data", (dataTable) => {
    })
    And('invoice is approved', () => {
    })
    And('invoice is funded', () => {
    })
    And('invoice is redeemed', () => {
    })
    Then('invoice created with following data', (dataTable) => {
    })

repository to be cloned: https://github.com/CreditPlace/automation.git

Versions

"dependencies": { "cypress-downloadfile": "^1.2.0", "cypress-get-table": "^1.0.1", "cypress-tags": "0.0.21", "randomstring": "^1.1.5" },"devDependencies": { "cypress": "^7.1.0", "cypress-cucumber-preprocessor": "^2.5.5", "cypress-file-upload": "^4.1.1", "cypress-log-to-output": "^1.1.2", "cypress-multi-reporters": "^1.4.0", "mocha": "^8.3.0", "mochawesome": "^6.2.1", "mochawesome-merge": "^4.2.0", "mochawesome-report-generator": "^5.1.0", "npm-run-all": "^4.1.5" }

badeball commented 3 years ago

I'm not able to access the repository you're referring to.

lgandecki commented 3 years ago

Thanks for the report, please make the repository public, I get 404 when I try to access. I also see you are using windows, are you sure this worked on windows before? There are some hardcoded paths with "/" in the cypress-tags script, which might be causing issues

raisapirgari commented 3 years ago

@badeball @lgandecki thanks for such a quick response. Unfortunately I can't make the repository public, but I can provide everything you need. Also I'm sure it worked before, unless some mistakes were made, I tried to review everything that was changed and before that we had even cucumber reports generated based on tags. Also when trying to run basic script with no configs it fails with same error: image

In case you can guide me to direction this error is coming from it, it will help a lot.

Thanks in advance.

badeball commented 3 years ago

Unfortunately I can't make the repository public, but I can provide everything you need.

What we need is a way to reproduce the issue locally, preferably with a repository we can clone. I understand that you can't share intellectual property with us, but you need to condense the problem into something that's free of that, minimal, and can be shared.

lgandecki commented 3 years ago

it looks like it might be this line failing:

const spec = ${fs.readFileSync(featurePath)};

and that probably means that the featurePath points to a directory. could you maybe change the cypress-tags.js file and do:

const paths = glob
  .sync(specGlob, {
    nodir: true,
    ignore: usingCypressConf ? ignoreGlob : "",
  })
  .filter((pathName) => pathName.endsWith(".feature"));

console.log("paths", paths)

and see whether all the paths are files, not directories? Another thing to check - do you have any folders that end with .feature ?

raisapirgari commented 3 years ago

Guys @badeball @lgandecki many many thanks, in my case is was a folder with .feature extension: image