Does anyone have any best practices/recipes for E2...
# best-practices
p
Does anyone have any best practices/recipes for E2E testing web socket applications where 3+ users are interacting simultaneously? I've been wracking my brain on this one and I think I've finally got a reasonable work around. My app is a game played by two players, and up until now, I've used one socket connection in my app code and one that gets directly instantiated in my test code (commands file) in order to make requests directly on behalf of an unseen user to trigger socket events that are then reflected in the UI. This works well because my backend recognizes the two socket connections as separate sessions and therefore lets me make arbitrary chains of interactions on behalf of the user who's UI the tests see, and the unseen user controlled by the test code. But when I tried to configure an additional test-controlled socket connection to test a WIP feature where one user can spectate a game played by two other users, I've had difficulty configuring things so that the two connections controlled by the test code can use different cookies and be separately authenticated. How do people normally test applications where many users interact in real time with websockets? My solution right now is basically to create a testing-only endpoint for updating a given browser session to point to a given user's data based on the database, and to use this to swap between the unseen players before making requests to make moves on their behalf while the app sits in spectate mode and listens to the socket events. I think this will get the job done for my use case, but I'm wondering how other people might have addressed the issue of testing multi-user applications that use web sockets
3 Views