GithubHelp home page GithubHelp logo

Comments (7)

badeball avatar badeball commented on July 20, 2024

I'm not seeing the same error using your example. It runs seemingly fine, aside from the first test which fails (expectedly) with ENOENT: no such file or directory, scandir 'cypress/downloads'.

FYI, your example doesn't even contain @cypress/browserify-preprocessor as a dependency. Have you actually tried to run the example you're providing me?

from cypress-cucumber-preprocessor.

daviddealvarado-clarivate avatar daviddealvarado-clarivate commented on July 20, 2024

Hi! I am not sure about the @cypress/browserify-preprocessor dependency but just to make sure I just copied an example from your repo. The failure of the first test should not be related to the fact of a missing folder (I don't know why it got deleted after my push to the repo because I added a .gitkeep to make sure it wasn't deleted.

Of course I run the example, actually the error codes were copied from that run. I have just push an update adding the dependency and I attach an screenshot of the run failure (the downloads folder is existing):

image

from cypress-cucumber-preprocessor.

badeball avatar badeball commented on July 20, 2024

This happens because you're hogging the plugin thread with sync calls to fs for 100s. Do the calls asynchronously, add some time between each check and reduce 100s to something more appropriate. Then you'll see the errors go away.

from cypress-cucumber-preprocessor.

badeball avatar badeball commented on July 20, 2024
--- a/cypress.config.ts
+++ b/cypress.config.ts
@@ -59,7 +59,7 @@ export default defineConfig({
       });
 
       cypressOn('task', {
-        getDownloadedFileName() {
+        async getDownloadedFileName() {
           let files;
           let start = Date.now();
           let elapsed = Date.now();
@@ -70,7 +70,8 @@ export default defineConfig({
               return str.endsWith('.xlsx') || str.endsWith('.ris') || str.endsWith('.csv');
             });
             elapsed = Date.now() - start;
-          } while (files.length < 1 && elapsed < 100000);
+            await sleep(100);
+          } while (files.length < 1 && elapsed < 1000);
 
           if (files.length > 0) {
             // It's an array but will/should have only one element
@@ -86,3 +87,7 @@ export default defineConfig({
     }
   },
 });
+
+function sleep (ms) {
+  return new Promise(resolve => setTimeout(resolve, ms))
+}

from cypress-cucumber-preprocessor.

daviddealvarado-clarivate avatar daviddealvarado-clarivate commented on July 20, 2024

I agree with the point of using the async call to be able to sleep, I will make that change to be more efficient.

I also understand that it might seem a lot of wait time, but the thing is that in my particular case the file is generated on the fly and may take up to 5m to be ready to be read.
Also, I don't the thinks the time waiting is a reason to make the state to be in something unexpected.
One could always configure the cy.task timeout to be 100s instead of the standard 30s or 1s if you want and IMHO that shouldn't raise an exception other than a timeout if there is any internal limitation, but not an unexpected behaviour, isn't it?

from cypress-cucumber-preprocessor.

badeball avatar badeball commented on July 20, 2024

Also, I don't the thinks the time waiting is a reason to make the state to be in something unexpected.

You can wait for whatever amount you want, but don't hog the plugin thread with sync calls. It makes Cypress behave incorrectly, as shown by timing out on screenshot, as well as on the internal task named cypress-cucumber-preprocessor:test-step-finished.

Said task doesn't actually take up any time. You can set a timeout for as long as you want, but as long as you hog the plugin thread it won't matter. By hogging the thread, you prevent the plugin from doing its job and that's why there's a state error.

from cypress-cucumber-preprocessor.

daviddealvarado-clarivate avatar daviddealvarado-clarivate commented on July 20, 2024

Understood. I will try to apply you recommendations and see how it behaves

from cypress-cucumber-preprocessor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.