Is there a better way to test?


I use luaunit to test my lua custom runtime code.

I have many lua custom functions to send opcodes to players via dispatcher during match-related event, but i dont know how to to test opcodes broadcast functionality properly.

-- sample code
local function send_opcode_1(state, dispatcher)
   -- build opcode_payload from state here

Is there a recommended way to test it?


Hi @renhades. The "nakama" module in the server is developed as native code through the interop bridge within the Lua VM we use. Unfortunately it’s not a file you can import into your test framework.

Is there a recommended way to test it?

The recommended way to test that I prefer is to use busted and mock the Nakama library itself. That way you’ll skip over network calls like dispatcher.broadcast_message these API calls are already tested extensively within Nakama and our various internal test suites.

Thanks for replies!