mcpField
R
roblox-testing

roblox-testing

github.com/tabooharmonyTesting & quality150145 installsUpdated 2w ago
Repository

About roblox-testing

A Roblox-focused testing skill for developers writing Luau unit and integration tests. It covers TestEZ, service mocks, dependency injection, and CI/CD workflows using Lune.

Key features

  1. 01TestEZ test structure and assertions
  2. 02Dependency injection for testability
  3. 03Mocks for Roblox services and signals
  4. 04Lune-based CI/CD pipeline
  5. 05Testing priorities and pitfalls

Use cases

  1. 01Testing Luau modules with TestEZ
  2. 02Mocking DataStore and remote events
  3. 03Running tests in CI with Lune
  4. 04Refactoring code to inject dependencies

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/tabooharmony/roblox-brain --skill roblox-testing

After installing, type/roblox-testingin Claude Code to confirm it loaded.

Bundled filesreferences/full.md

Details

From the project README

When to Load

Load when writing unit/integration tests, mocking Roblox services, setting up CI/CD with Lune, or refactoring code for testability via dependency injection. Hand off to roblox-luau-core for syntax, roblox-luau-types for type design, roblox-luau-patterns for architecture, roblox-security for validation.

Quick Reference

TestEZ (BDD framework)
  • Install: [dev-dependencies] TestEZ = "roblox/[email protected]" in wally.toml
  • Files: *.spec.luau, co-located with source
  • Blocks: describe → it → beforeEach/afterEach
  • Assertions: expect(x).to.equal(y), .to.be.near(n, ε), .to.throw()
Dependency Injection
-- BAD: untestable outside Studio
local store = game:GetService("DataStoreService"):GetDataStore("PlayerData")
-- GOOD: inject dependency
local function saveData(player, data, dataStore)
    dataStore:SetAsync("player_" .. player.UserId, data)
end
-- Module init pattern:
function Manager.init(dataStoreService)
    _dss = dataStoreService or game:GetService("DataStoreService")
end
Mocking Essentials
-- MockDataStore: in-memory Get/Set/Update
local M = {}
function M.new() return setmetatable({_data={}}, {__index=M}) end
function M:GetAsync(k) return self._data[k] end
function M:SetAsync(k,v) self._data[k]=v end
function M:GetDataStore() return self end
-- MockRemoteEvent: OnServerEvent + FireServer
-- MockSignal: Connect/Fire with Connected flag
CI/CD with Lune
# aftman.toml
[tools]
lune = "lune-org/[email protected]"

Pipeline: selene src/ → stylua --check src/ → luau-lsp analyze → lune run tests/run.luau

-- tests/run.luau
local TestEZ = require("@testez")
local results = TestEZ.TestBootstrap:run({game:GetService("ReplicatedStorage")}, TestEZ.Reporters.TextReporter)
if results.failureCount > 0 then os.exit(1) end
Testing Priority
  1. DataStore save/load round-trips (prevents data loss)
  2. Monetization ProcessReceipt (idempotency)
  3. Core math (damage, buffs, economy)
  4. Server validation (remote exploits)
Pitfalls
  • beforeEach to reset state; never game:GetService() in logic
  • Tests must be order-independent; CI needs mocks; commit wally.lock Need more detail? Load references/full.md for the complete reference with code examples, API tables, and edge cases.

Comments

Markdown supported