Using require in test script causes "Module code did not return exactly one value" error
psdillon opened this issue · comments
When I use require in a test script, the test is not executed and "Module code did not return exactly one value" is reported in the output window. I'm using the plugin test runner.
MyModule:
local module = {}
module.test3 = function()
print("test3")
return 3
end
return module
MyTest:
local NexusUnitTesting = require("NexusUnitTesting")
local myModule = require(script.Parent.MyModule)
NexusUnitTesting:RegisterUnitTest("TestName1",function(UnitTest)
UnitTest:AssertEquals(1 + 1,2,"Addition doesn't work.")
--UnitTest:AssertEquals(myModule.test3(), 3, "Should be 3")
end)
All ModuleScript
s in Roblox requires exactly 1 value to be returned regardless of how it is set up. This probably should be reported in Roblox's script analysis, but it doesn't. The test code I use has return true
at the end of all tests because of this. I don't intend to resolve this because Roblox could introduce a change that causes issues for place files that have ModuleScript
s that don't return anything.
Ah thankyou, I thought it was complaining about MyModule, and not realising I had lost the return on MyTest.