Cypress 10 vs Cucumber vs Esbuild compatibility

Viewed 54

I used Cypress 10 for a while with Cucumber preprocessor. Everything worked without issues. Today I updated Cypress to the latest version 10.7.0 and also @badeball/cypress-cucumber-preprocessor to 12.2.0. I have there also @bahmutov/cypress-esbuild-preprocessor 2.1.3

In my cypress.config.js file I have:

      e2e: {
        baseUrl: 'http://localhost:4200',
        specPattern: 'cypress/e2e/features',
        setupNodeEvents(on, config) {
          const createEsbuildPlugin =
          require('@badeball/cypress-cucumber-preprocessor/esbuild').createEsbuildPlugin
          const createBundler = require('@bahmutov/cypress-esbuild-preprocessor')
          require('@badeball/cypress-cucumber-preprocessor').addCucumberPreprocessorPlugin
    
          on('file:preprocessor',   createBundler({
            plugins: [createEsbuildPlugin(config)],
          }));
        }

  },

But now, when I start Cypress test runner, all the test are still there (all feature files), but after I click on ANY test case, I have this error:

Error: Build failed with 1 error:
node_modules/common-ancestor-path/index.js:17:37: ERROR: [plugin: feature] Reduce of empty array with no initial value
    at failureErrorWithLog (C:\Users\JS\Desktop\test\node_modules\esbuild\lib\main.js:1605:15)
    at C:\Users\JS\Desktop\test\node_modules\esbuild\lib\main.js:1251:28
    at runOnEndCallbacks (C:\Users\JS\Desktop\test\node_modules\esbuild\lib\main.js:1034:63)
    at buildResponseToResult (C:\Users\JS\Desktop\test\node_modules\esbuild\lib\main.js:1249:7)
    at C:\Users\JS\Desktop\test\node_modules\esbuild\lib\main.js:1358:14
    at C:\Users\JS\Desktop\test\node_modules\esbuild\lib\main.js:666:9
    at handleIncomingPacket (C:\Users\JS\Desktop\test\node_modules\esbuild\lib\main.js:763:9)
    at Socket.readFromStdout (C:\Users\JS\Desktop\test\node_modules\esbuild\lib\main.js:632:7)
    at Socket.emit (node:events:527:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at Readable.push (node:internal/streams/readable:234:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23)

And also Cypress says: No tests found. Cypress could not detect tests in this file.

Seems the issue is with esbuild, but not sure. I tried to downgrade the cucumber preprocessor, then it is working again.

Seems it is a compatibility problem between cucumber and esbuild.

Each library is managed by someone else, they do not cooperate, so I am really thinking to stop using Cucumber, but only pure Cypress.

0 Answers
Related