Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress don't support while(true), just beacause it's async? #25929

Closed
yangislet opened this issue Feb 23, 2023 · 1 comment
Closed

Cypress don't support while(true), just beacause it's async? #25929

yangislet opened this issue Feb 23, 2023 · 1 comment
Labels
E2E Issue related to end-to-end testing type: feature New feature that does not currently exist

Comments

@yangislet
Copy link

yangislet commented Feb 23, 2023

What would you like?

We often use a test mode, which includes a server and client, so that we can easily control the steps of each test case. Usually the client is only responsible for generating test cases and sending test cases, and the server is responsible for the real test case execution. implement. For example, Python builds a client, which is only responsible for sending JSON test cases. As a server, cypress is responsible for receiving JSON test cases, translating them into test cases for execution, and returning the direct results of the current test cases to the client. If Cypress doesn't support While(TRUE) mode, how can I dynamically add test cases to Cypress execution thread? In the Python Asyncio library, they provide the asyncio.run_coroutine_threadsafe function, which allows users to dynamically add tasks to the loop thread, but why doesn't Cypress provide the corresponding function?

Why is this needed?

We need Api that allow user dynamiclly append case to Cypress

const socket = io("http://localhost:5000");
var ui_case = null;
describe("template spec", () => {
  before(() => {
    cy.log("set up socket client"); 
    socket.on("connect", () => { 
      console.log("socket connect");
    });
    socket.on("disconnect", () => {
      console.log("socket disconnect");
    });
    socket.on("connect_error", (e) => {
      console.log("socket connect error", e.message);
    });

    socket.on("uicase", (data) => {
      console.log("get ui case data");
      ui_case = data;
    });

  });
  
  it("wait new ui case data", () => {
    cy.log("wait for new case"); 
    while (true) { 
      //test ui case
      if(ui_case != null){
        // translate json data to cypress api and excute case
        
        ui_case = null;
      } 
    }
  });
});

Other

No response

@nagash77 nagash77 added type: feature New feature that does not currently exist E2E Issue related to end-to-end testing labels Feb 23, 2023
@emilyrohrbough emilyrohrbough removed their assignment Mar 1, 2023
@marktnoonan
Copy link
Contributor

Thanks for reporting this and showing the example, I'm going to close this as a duplicate of some related issues that are already on our radar:

#3757
#3114

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing type: feature New feature that does not currently exist
Projects
None yet
Development

No branches or pull requests

4 participants