Skip to main content

Midori

Functions

runTests

This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. Yields
Midori.runTests(
rootInstance,
configConfig?
) → ()

Types

interface Config {
showTimeoutWarningboolean?--

If true, a warning will show if a test runs longer than timeoutWarningDelay

timeoutWarningDelaynumber?--

Time in seconds for a test to show a timeout warning

concurrentboolean?--

If true, all tests will run concurrently

}

Runs the tests found in all the .test modules inside of the root instance.

Example:

Midori.runTests(YourLibrary, {
	timeoutWarningDelay = 10,
})

Default config values:

{
	showTimeoutWarning = true,
	timeoutWarningDelay = 15,
	concurrent = false,
}
caution

The concurrent option should only be used if your tests do not affect each other at all. If used, tests should not access variables other tests access. The code that is being tested should also not contain any global state.

Show raw api
{
    "functions": [
        {
            "name": "runTests",
            "desc": "Runs the tests found in all the `.test` modules inside of the `root` instance.\n\nExample:\n```lua\nMidori.runTests(YourLibrary, {\n\ttimeoutWarningDelay = 10,\n})\n```\n\nDefault config values:\n```lua\n{\n\tshowTimeoutWarning = true,\n\ttimeoutWarningDelay = 15,\n\tconcurrent = false,\n}\n```\n\n:::caution\nThe `concurrent` option should only be used if your tests do not affect each other at all. If used, tests should not access\nvariables other tests access. The code that is being tested should also not contain any global state.\n:::",
            "params": [
                {
                    "name": "root",
                    "desc": "",
                    "lua_type": "Instance"
                },
                {
                    "name": "config",
                    "desc": "",
                    "lua_type": "Config?"
                }
            ],
            "returns": [],
            "function_type": "static",
            "yields": true,
            "source": {
                "line": 60,
                "path": "src/init.lua"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "Config",
            "desc": "",
            "fields": [
                {
                    "name": "showTimeoutWarning",
                    "lua_type": "boolean?",
                    "desc": "If `true`, a warning will show if a test runs longer than `timeoutWarningDelay`"
                },
                {
                    "name": "timeoutWarningDelay",
                    "lua_type": "number?",
                    "desc": "Time in seconds for a test to show a timeout warning"
                },
                {
                    "name": "concurrent",
                    "lua_type": "boolean?",
                    "desc": "If `true`, all tests will run concurrently"
                }
            ],
            "source": {
                "line": 15,
                "path": "src/init.lua"
            }
        }
    ],
    "name": "Midori",
    "desc": "",
    "source": {
        "line": 30,
        "path": "src/init.lua"
    }
}