Файли
openidea/src/features/run/targetDebug.test.ts
T
LU XIANGRUIтаwildcatDownstairs 9b578c2fad feat(run): debug Node.js on SSH, Docker and Compose run targets (#6919)
Debug on a Node.js configuration or a .js / .ts file run whose run target is SSH, Docker or Compose now debugs the program there, extending the Python flow. A js-debug configuration starts node with --inspect-brk on a free port (0.0.0.0 inside the container, published on this machine's loopback only; the host's loopback over the existing SSH forward). The run prints the project folder on the target as a system line, which the frontend reads to map sources before attaching js-debug. tsx is refused for now (it hangs once js-debug attaches); other programs get an error naming the fix.

Closes #6901

Co-authored-by: wildcatDownstairs <[email protected]>

Co-authored-by: wildcatDownstairs <[email protected]>
2026-11-30 11:52:59 +08:00

32 рядки
1.5 KiB
TypeScript

import { describe, expect, it } from "vitest";
import type { RunConfig } from "@/platform/ipc";
import { debugpyReady, inspectorPort, nodeDebugFolder, targetDebugLaunch } from "./targetDebug";
describe("debugging on run targets", () => {
it("reads the port and the project folder from the bootstrap's line", () => {
expect(
debugpyReady("debugpy is waiting for the debugger on port 41234, project folder /workspaces/my app\r"),
).toEqual({
port: 41234,
remoteRoot: "/workspaces/my app",
});
expect(debugpyReady("waiting for the debugger on port 41234")).toBeNull();
});
it("reads the project folder from the IDE's line and the port from Node's", () => {
expect(nodeDebugFolder("Starting Node.js for the debugger, project folder /workspaces/my app\r")).toBe(
"/workspaces/my app",
);
expect(nodeDebugFolder("debugpy is starting")).toBeNull();
expect(inspectorPort("Debugger listening on ws://0.0.0.0:41234/9f1c2e3a-0000\r")).toBe(41234);
expect(inspectorPort("Debugger listening on ws://[::1]:9229/abc")).toBe(9229);
expect(inspectorPort("For help, see: https://nodejs.org/en/docs/inspector")).toBeNull();
});
it("asks the backend for a debug run, keeping the configuration's parameters", () => {
const config = { id: "a", params: { module: "app" } } as unknown as RunConfig;
expect(targetDebugLaunch(config).params).toEqual({ module: "app", targetDebug: "true" });
expect(config.params).toEqual({ module: "app" });
});
});