Skip to content

Testing

AppCubeThere's a built-intest runner, can be used for unit testing.

After suffix_testThe script at the end is a unit test script and must follow the format of the unit test script.

Writing test cases

ts
import { test } from "testing";
import * as assert from "assert";

test("hello world #1", function () {
    const x = 1 + 2;
    assert.equal(x, 3, "");
})

test("hello world #2", function () {
    const x = 1 + 2;
    assert.equal(x, 3, "");
})

Run test code

Same as running a normal script. The output is as follows:

ts
[
    {
        "message": "",
        "name": "hello world #1",
        "success": true
    },
    {
        "message": "",
        "name": "hello world #2",
        "success": true
    }
]