cypress-esbuild-preprocessor icon indicating copy to clipboard operation
cypress-esbuild-preprocessor copied to clipboard

Compiling of files keeps failing when there is a bad import statement

Open Bertg opened this issue 3 years ago • 1 comments

I originally opened an issue on badeball/cypress-cucumber-preprocessor. The maintainer pointed out that the issue is within this package.

So the report here is the original report, including some badeball/cypress-cucumber-preprocessor related info:

Current behavior

Given I have a step definition file that contains an invalid (relative) import
When I start cypress and try to run that feature
Then I get the following error
  > Error: Build failed with 1 error:
  > cypress/e2e/test.js:1:42: ERROR: Could not resolve "../support/helpers"
When I then fix the broken import
Then I still get the error

Desired behavior

When the broken import is fixed, the feature should start running.

Test code to reproduce

https://github.com/younited/cypress_cucumber_import_bug

Instructions on how to replicate the issue are in the readme.

Versions

  • Cypress version: 10.4.0
  • Cypress version: 10.4.0
  • Esbuild Preprocessor version: 2.1.3
  • Esbuild version: 0.14.51
  • Node version: 16.14.2

Bertg avatar Aug 04 '22 07:08 Bertg

https://github.com/sod/cypress-esbuild-preprocessor#readme seems to work as an alternative.

Or you could try disabling the preprocessor's file watching which seems to indirectly resolve the problem e.g.

const createBundler = require('@bahmutov/cypress-esbuild-preprocessor')

module.exports = (on, config) => {
  const filePreprocessor = createBundler({
    // ...whatever your config is
  });

  on('file:preprocessor', (file) => {
    file.shouldWatch = false;
    return filePreprocessor(file);
  });
}

MDG-JHowley avatar Oct 11 '23 12:10 MDG-JHowley