RAS Playground 日本語 GitHub

Run, test and debug

Debugging

With the VS Code extension installed, place a breakpoint in a .ras file and run with F5 (or "RAS: Start debugging"). Stepping, inspecting variables and watch expressions, and stopping on exceptions are available.

This is not VBA debugging. The program is converted to JavaScript and run on the runtime bundled with VS Code, and only the Excel operations are performed against Excel (spec §14.10).

You can also start a function directly from the CodeLens "▶ Run in Excel | Debug" above it. "Run in Excel" syncs to the workbook and then runs it as a macro in Excel itself (Windows only), and "Debug" starts a debug run with that function. You can also pin the function in launch.json.

{ "type": "ras", "request": "launch", "name": "RAS: rebuildReport", "entry": "Report.rebuildReport" }

The debugger statement

Writing debugger; in the source makes the debug run stop at that line. Nothing is output to VBA (spec §14.10.9).

export function inspect() {
    const last = Sheet1.lastRow();
    debugger;                        // stops here
    debug.print(last);
}

In the playground, you can debug by placing breakpoints in the .ras files at ras://project/… under "Sources" in the browser's developer tools (F12) (spec §14.10.10).

Details of working in VS Code, such as the launch.json fields, debugging-related settings and test generation, are in the VS Code extension.