Thanks for posting your solution. I'm also going to cover my codebase with unit tests before it grows out of control, your solution is a good starting point for me, although I believe it's not the best way to go long-term wise. All this global environment looks like a pain to test with. I think what we can do instead is having every module each piece it depends on during the construction instead of letting it blindly using global environment in it's methods. Should dig more into this. Just thinking out loud. I guess it was a pain to compose the game state mock (https://github.com/Jomik/screeps/blob/master/lib/mocks/mockGameState.js) wasn't it... Did you go over the API and manually picked the constants / objects / functions from there? Thanks for posting this. I think you're among the first explorers of unit testing in screeps, if not the first one