Skip to main content

NevermoreTestResults

Turns what Jest resolved with into the results table a test run returns.

Deliberately dependency-free: no loader, no Jest, no print or warn. This logic has produced three bugs — counts read off the wrong table, jest-lua's inverted success field, and double-counted failed suites — every one of them shipped green because a module-scope Jest require made it impossible to unit test. It takes plain tables and returns plain tables so a test can drive it anywhere, including under Lune (see test/results.test.luau).

The caller does the logging.

Types

TestFailure

interface TestFailure {
namestring--

Full test name, or the suite's script path for a suite-level failure

messagestring?--

First failure message, truncated

}

One failed test, or one suite that failed before its tests could run.

TestRunResults

interface TestRunResults {
formatstring--

Always NevermoreTestResults.FORMAT

successboolean--

Whether the run is a pass

ranJestboolean--

False for a smoke test, where the counts are all zero because nothing counted

passednumber
failednumber
skippednumber--

Pending plus todo

totalnumber
suitesPassednumber
suitesFailednumber
suitesTotalnumber
failures{TestFailure}--

Capped; omittedFailures says how many did not fit

omittedFailuresnumber
errorstring?--

Why the run failed; absent on a pass

}

What a test run produced. Only ever plain strings, numbers, booleans and tables of those: the cloud and the Studio bridge marshal exotic values differently, and this subset survives both unchanged.

Properties

FORMAT

NevermoreTestResults.FORMAT: string

Tag identifying a TestRunResults table to whatever reads a run's return values. A test place also runs probe scripts that return whatever they like, so a reader matches on this rather than on the table's shape.

Functions

new

NevermoreTestResults.new(ranJestboolean) → TestRunResults

Builds an all-zero passing result. Every other result is this with counts filled in, so a caller never has to handle a missing field.

failed

NevermoreTestResults.failed(
ranJestboolean,
messagestring--

Why the run failed. Required: a failure with no reason is unreadable.

) → TestRunResults

Builds a failed result carrying no counts, for a run that never produced any.

fromJest

NevermoreTestResults.fromJest(
resolvedany--

The value Jest.runCLI's promise resolved with

) → TestRunResults

Reads the verdict and the counts out of whatever Jest.runCLI resolved with.

Fails closed on anything it cannot read. Defaulting an unreadable count to zero instead is what let two wrong reads of this ship: no failures over no tests reads exactly like a clean run.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Builds an all-zero passing result. Every other result is this with counts\nfilled in, so a caller never has to handle a missing field.",
            "params": [
                {
                    "name": "ranJest",
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "TestRunResults"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 209,
                "path": "src/nevermore-test-runner/src/Server/NevermoreTestResults.lua"
            }
        },
        {
            "name": "failed",
            "desc": "Builds a failed result carrying no counts, for a run that never produced any.",
            "params": [
                {
                    "name": "ranJest",
                    "desc": "",
                    "lua_type": "boolean"
                },
                {
                    "name": "message",
                    "desc": "Why the run failed. Required: a failure with no reason is unreadable.",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "TestRunResults"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 233,
                "path": "src/nevermore-test-runner/src/Server/NevermoreTestResults.lua"
            }
        },
        {
            "name": "fromJest",
            "desc": "Reads the verdict and the counts out of whatever `Jest.runCLI` resolved with.\n\nFails closed on anything it cannot read. Defaulting an unreadable count to\nzero instead is what let two wrong reads of this ship: no failures over no\ntests reads exactly like a clean run.",
            "params": [
                {
                    "name": "resolved",
                    "desc": "The value Jest.runCLI's promise resolved with",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "TestRunResults"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 251,
                "path": "src/nevermore-test-runner/src/Server/NevermoreTestResults.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "FORMAT",
            "desc": "Tag identifying a [TestRunResults] table to whatever reads a run's return\nvalues. A test place also runs probe scripts that return whatever they like,\nso a reader matches on this rather than on the table's shape.",
            "lua_type": "string",
            "source": {
                "line": 25,
                "path": "src/nevermore-test-runner/src/Server/NevermoreTestResults.lua"
            }
        }
    ],
    "types": [
        {
            "name": "TestFailure",
            "desc": "One failed test, or one suite that failed before its tests could run.",
            "fields": [
                {
                    "name": "name",
                    "lua_type": "string",
                    "desc": "Full test name, or the suite's script path for a suite-level failure"
                },
                {
                    "name": "message",
                    "lua_type": "string?",
                    "desc": "First failure message, truncated"
                }
            ],
            "source": {
                "line": 64,
                "path": "src/nevermore-test-runner/src/Server/NevermoreTestResults.lua"
            }
        },
        {
            "name": "TestRunResults",
            "desc": "What a test run produced. Only ever plain strings, numbers, booleans and\ntables of those: the cloud and the Studio bridge marshal exotic values\ndifferently, and this subset survives both unchanged.",
            "fields": [
                {
                    "name": "format",
                    "lua_type": "string",
                    "desc": "Always [NevermoreTestResults.FORMAT]"
                },
                {
                    "name": "success",
                    "lua_type": "boolean",
                    "desc": "Whether the run is a pass"
                },
                {
                    "name": "ranJest",
                    "lua_type": "boolean",
                    "desc": "False for a smoke test, where the counts are all zero because nothing counted"
                },
                {
                    "name": "passed",
                    "lua_type": "number",
                    "desc": ""
                },
                {
                    "name": "failed",
                    "lua_type": "number",
                    "desc": ""
                },
                {
                    "name": "skipped",
                    "lua_type": "number",
                    "desc": "Pending plus todo"
                },
                {
                    "name": "total",
                    "lua_type": "number",
                    "desc": ""
                },
                {
                    "name": "suitesPassed",
                    "lua_type": "number",
                    "desc": ""
                },
                {
                    "name": "suitesFailed",
                    "lua_type": "number",
                    "desc": ""
                },
                {
                    "name": "suitesTotal",
                    "lua_type": "number",
                    "desc": ""
                },
                {
                    "name": "failures",
                    "lua_type": "{ TestFailure }",
                    "desc": "Capped; `omittedFailures` says how many did not fit"
                },
                {
                    "name": "omittedFailures",
                    "lua_type": "number",
                    "desc": ""
                },
                {
                    "name": "error",
                    "lua_type": "string?",
                    "desc": "Why the run failed; absent on a pass"
                }
            ],
            "source": {
                "line": 90,
                "path": "src/nevermore-test-runner/src/Server/NevermoreTestResults.lua"
            }
        }
    ],
    "name": "NevermoreTestResults",
    "desc": "Turns what Jest resolved with into the results table a test run returns.\n\nDeliberately dependency-free: no loader, no Jest, no `print` or `warn`. This\nlogic has produced three bugs — counts read off the wrong table, jest-lua's\ninverted `success` field, and double-counted failed suites — every one of them\nshipped green because a module-scope Jest require made it impossible to unit\ntest. It takes plain tables and returns plain tables so a test can drive it\nanywhere, including under Lune (see `test/results.test.luau`).\n\nThe caller does the logging.",
    "source": {
        "line": 16,
        "path": "src/nevermore-test-runner/src/Server/NevermoreTestResults.lua"
    }
}