i've began sketching a simulated implementation of nodemcu api, where callbacks would be working reasonably well and one can control time and data traffic.
one has to clone https://github.com/fikin/nodemcu-lua-mocks and include the files in its own project.
and btw, feel most welcome to help make it better.
here is how one can test alarm:
require('tmr')
local fired = false
tmr.create(1,tmr.ALARM_SINGLE,function(timerObj)
fired = true
end):start()
Timer.joinAll(2) -- advance time with 2ms
luaunit.assertTrue(fired)
there is already reasonably well working implementation for wifi, net, gpio, adc and few more.