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

cypress doesn't wait for preprocessor to compile the`.feature` file

Open mysticdevx opened this issue 1 year ago • 4 comments

Current behavior

When cypress has the watchForFileChanges: false config setting that disables cypress run after each test file modification, then cypress doesn't wait for .feature file to be compiled. That results us to run the feature file twice if the file is new, and worst is, it doesn't reflect the latest change in the existing test code unless we run it twice. (i.e. for an existing test, I change, say an assertion, and when i run the test, it uses the previously compiled .feature file bc cypress doesnt wait for the new compilation, and uses the existing one)

Example SS

Screenshot 2024-10-06 at 14 54 34

Desired behavior

It would be nice, if tests start after preprocessor compiles the feature file, so that we can use the watchForFileChanges: false that makes test development easier. (otherwise cypress keeps running during development after each change)

Some workarounds are listed here, however neither of them works. Therefore i needed to open an issue.

Thanks.

Test code to reproduce

You can use this repo.

Versions

  • Cypress version: 13.15.0
  • Preprocessor version: 21.0.2
  • Node version: 18.20.2

Checklist

mysticdevx avatar Oct 06 '24 13:10 mysticdevx

Hi @mysticdevx, you need to clearly outline the steps needed to exemplify the undesired behavior. Furthermore, since I suspect this has something to do with https://github.com/bahmutov/cypress-esbuild-preprocessor/issues/380, I ask that you try this using non-cucumber tests while using the esbuild bundler, to see if it is infact there the problem lies.

badeball avatar Oct 06 '24 14:10 badeball

I dont think its about compile error, bc the files are compiled, just its too late for cypress to detect the changes (I say this bc when watch mode is true, i see cypress runs twice in very small interval of time, and when watch mode is false every second attpemt make it run).

But ok, its logical to isolate the issue if its only about cucumber preprocessor - i dint think of it :( I'll try with non-cucumber / esbuild preprocessor to isolate the issue, then if necessary will add steps to reproduce. Thanks.

mysticdevx avatar Oct 06 '24 14:10 mysticdevx

Any luck getting this issue resolved? I have run into it sporadically multiple times with no clear steps to resolve. Hit and trial with different steps sometimes work though, example: Yarn cache clean Install newer version of Cypress Updated preprocessor and esbuild-preprocessor dependencies and reverted back, tried different versions of testing library as well Cypress cache clear and reinstall Cypress Clear content of Developer Tools-App Data Delete the local instance of the project and rebuild from BB

nids2307 avatar Nov 18 '24 16:11 nids2307

This works for me: https://github.com/bahmutov/cypress-esbuild-preprocessor/issues/195#issuecomment-1757611761

MDG-JHowley avatar Nov 29 '24 14:11 MDG-JHowley

https://github.com/bahmutov/cypress-esbuild-preprocessor/issues/380 was recently fixed and closed. @mysticdevx, @nids2307 and @MDG-JHowley, can you try using the latest @bahmutov/cypress-esbuild-preprocessor (v2.2.7) and see if the behavior is changed?

badeball avatar Oct 25 '25 07:10 badeball

hi @badeball, as @MDG-JHowley mentioned, without the below setting, its still the same.

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

cypress: 15.5.0 cypress-cucumber-preprocessor: 23.2.1 cypress-esbuild-preprocessor: 2.2.7

mysticdevx avatar Nov 01 '25 08:11 mysticdevx

I was able to reproduce this, even without using this preprocessor. An example can be seen here. You can consistently see the behavior by deleting AppData before running Cypress (where it caches bundles). @mysticdevx, I assume you're using WIndows too?

In any case, because this happens irregardless of whether this library is used, the issue must necessarily lie elsewhere. I recommend that you take this information and open up an issue on https://github.com/bahmutov/cypress-esbuild-preprocessor, where I suspect the error resides.

badeball avatar Nov 01 '25 16:11 badeball

FYI, this is caused by https://github.com/bahmutov/cypress-esbuild-preprocessor/pull/245. You can test it using @bahmutov/[email protected] and [email protected].

badeball avatar Nov 02 '25 20:11 badeball

FYI, this is adressed in https://github.com/bahmutov/cypress-esbuild-preprocessor/pull/515.

badeball avatar Nov 07 '25 14:11 badeball