This code causes the test to error with 'cannot spawn non-suspended coroutine with arguments', despite being valid when using real timers:
it("timer resume bug", function()
jest.useFakeTimers()
local thread
task.spawn(function()
task.wait()
coroutine.close(thread)
end)
thread = task.spawn(function()
task.wait()
-- no code should execute as this point, and there shouldn't be any errors
end)
jest.runAllTimers()
end)
If coroutine.close is swapped with task.cancel, any code after the task.wait() in the thread will still execute, whereas with real timers it won't.