bahmutov / cy-grep

Filter Cypress tests using title or tags
16 stars 4 forks source link

Error: ENOENT: no such file or directory, open '<file path>' being thrown from plugin #98

Open nerrante opened 3 months ago

nerrante commented 3 months ago

Hi Gleb,

Running into a weird issue after updating Cypress to 13 and updating all my libraries. I even did a clean npm install but no joy. I have recreated the issue on a public github repo - https://github.com/nerrante/cypresstest

I use multiple configuration files depending on the environment I'm running it in. I've used this set up successfully in the past with this plugin. I note this because if I take out the extra config file and merely run it from base cypress.config.ts file putting the grepTags there, it works fine.

The command I'm running is: npx cypress open --config-file config/test_configuration.config.ts Cypress opens, it shows as properly configured, and then when I click on E2E Testing I get the following error (with stack trace): Your configFile threw an error from: /Users/nerrante/Documents/cypresstest/config/test_configuration.config.ts The error was thrown while executing your e2e.setupNodeEvents() function:

Error: ENOENT: no such file or directory, open 'cypress/e2e/failing_tests/failing_test.spec.ts'
    at Object.readFileSync (node:fs:453:20)
    at /Users/nerrante/Documents/cypresstest/node_modules/@bahmutov/cy-grep/src/plugin.js:149:25
    at Array.filter ()
    at cypressGrepPlugin (/Users/nerrante/Documents/cypresstest/node_modules/@bahmutov/cy-grep/src/plugin.js:148:32)
    at setupNodeEvents (/Users/nerrante/Documents/cypresstest/cypress.config.ts:48:46)
    at /Users/nerrante/Library/Caches/Cypress/13.13.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:122:14
    at tryCatcher (/Users/nerrante/Library/Caches/Cypress/13.13.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/Users/nerrante/Library/Caches/Cypress/13.13.0/Cypress.app/Contents/Resources/app/node_modules/bluebird/js/release/method.js:39:29)
    at RunPlugins.load (/Users/nerrante/Library/Caches/Cypress/13.13.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:119:9)
    at RunPlugins.runSetupNodeEvents (/Users/nerrante/Library/Caches/Cypress/13.13.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_plugins.js:59:17)
    at EventEmitter. (/Users/nerrante/Library/Caches/Cypress/13.13.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/child/run_require_async_child.js:185:22)
    at EventEmitter.emit (node:events:518:28)
    at EventEmitter.emit (node:domain:488:12)
    at process. (/Users/nerrante/Library/Caches/Cypress/13.13.0/Cypress.app/Contents/Resources/app/packages/server/lib/plugins/util.js:33:22)
    at process.emit (node:events:518:28)
    at process.emit (node:domain:488:12)
    at process.emit.sharedData.processEmitHook.installedValue [as emit] (/Users/nerrante/Library/Caches/Cypress/13.13.0/Cypress.app/Contents/Resources/app/node_modules/@cspotcode/source-map-support/source-map-support.js:745:40)
    at emit (node:internal/child_process:951:14)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

I have debug turned on for cy-grep, the terminal output is as follows:

 cy-grep cy-grep plugin version 1.10.0 +0ms
  cy-grep Cypress config env object: { showLogs: true, numTestsKeptInMemory: 1, grepFilterSpecs: true, grepOmitFiltered: true, grepTags: '@regression' } +1ms
cy-grep: filtering using tag(s) "@regression"
  cy-grep parsed grep tags [ [ { tag: '@regression', invert: false } ] ] +1ms
cy-grep: will omit filtered tests
  cy-grep found 2 spec file(s) +5ms
  cy-grep [ 'cypress/e2e/failing_tests/failing_test.spec.ts', 'cypress/e2e/login/test.spec.ts' ] +0ms
  cy-grep parsed grep tags { title: [], tags: [ [ [Object] ] ] } +0ms
  cy-grep user mentioned tags [ '@regression' ] +0ms

Let me know if there's anything else that would be helpful - thanks! Nicole

nerrante commented 4 weeks ago

Hi Gleb - was just wondering if you had a chance to look at this? I have a work-around which is to just not extend the config files, but would love to not have to do that.

bahmutov commented 4 weeks ago

Did not have time to look into this, sorry about that, maybe you could open a PR with a fix to make it simpler to merge the fix?

nerrante commented 4 weeks ago

Hi Gleb - no worries - I would love to, but I don't know what the issue is (if I knew the fix, I would definitely do that!). I understand if you don't have time, just thought I'd check in!