Skip to content

Mocking / Patching / Testing #465

@aktary

Description

@aktary

I have a socket.io client that connects to a third-party's server. I'd like to write some tests using fixtures such that I'm validating that my client handles messages appropriately, but without actually connecting to the third party server. Note that in my case, I had to write a custom class-based namespace to have a catch-all for messages because of how the third party implemented their server.

My question is: how do I do this patch/mock? I'm thinking I'd mock the client.connect() call, so it doesn't actually connect to the server, but then how do I trigger the trigger_event() method?

I'm sure there's a simple answer to this that I'm not seeing, but I'd really appreciate some help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions