A significant hurdle to testing code, and managing a game in Roblox is the tightly coupled nature of the DataStore. A good idea for dealing with the added complexity is abstracting away the idea of storing information to a swapable or customizable memory backing system.
Unifying Read/Write to a DataStore
The DataStore for Roblox is really just a glorified table that is written to a database. More than likely this is backed by Redis, information that is not really important here.
When you think about data you think about 4 essential operations: Loading, Reading, Writing and Saving.
We can create a module that has a swapable interface, and then in our code use that. During testing we can then back all of the game state with an in-memory database, and when it’s time to deploy the game, we can swap out the Loading and Saving functions to actually use the real datastore.