I am just really confused. I was checking roact’s source code, and I found scripts that have “.spec” at the end of their name ([scriptName].spec). The scripts with .spec at the end of their name returned a function, with undefined functions inside of that function. Undefined functions such “it”, “describe”, “expect”, were some of the functions used. When I tried to play around with the functions, they just didn’t work.
snippet from assign.spec:
it("should accept zero additional tables", function()
local input = {}
local result = assign(input)
expect(input).to.equal(result)
end)
Now let me remind you that the corresponding script on roblox studio highlights them as a undefined function, and trying to call these modules result in an error. Is there any explanation to this?
Please explain how this works, because I am very confused.
The functions you are trying to use are the functions of a module script, which you define inside them. They are not global but defined in a module script.
local module = {}
function module.Print()
print("Hi!")
end
return module
And you can require this module script in another script.
local module = require(game:GetService("ReplicatedStorage").ModuleScript)
module.Print()
It was probably a custom function they made in that script. I’ve seen things like this before where people do local function functionName or something like that to use within their script. So no, these are not “real” functions. They are not part of Roblox’s built-in functions.
You have found Roact’s test cases. Roact uses TestEZ to make sure after any update their library still works correctly. These tests basically try and simulate an action to make sure it still returns the correct info.
Here is the github link GitHub - Roblox/testez: BDD-style test and assertion library for Roblox Lua