From d2ef2877918fa6d78592cafb1c6c7d0075928af4 Mon Sep 17 00:00:00 2001 From: Bedis Nbiba Date: Tue, 29 Jul 2025 00:45:41 +0100 Subject: [PATCH] Add runnable support for Deno.test (#34593) example of detected code: ```ts Deno.test("t", () => { console.log("Hello, World!"); }); Deno.test(function azaz() { console.log("Hello, World!"); }); ``` I can't build zed locally so I didn't test this, but I think the code is straightforward enough, hopefully someone else can verify it Closes #ISSUE Release Notes: - N/A --- crates/languages/src/typescript/runnables.scm | 41 ++++++++++++++++++- docs/src/languages/deno.md | 34 +++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/crates/languages/src/typescript/runnables.scm b/crates/languages/src/typescript/runnables.scm index 85702cf99d..6bfc536329 100644 --- a/crates/languages/src/typescript/runnables.scm +++ b/crates/languages/src/typescript/runnables.scm @@ -1,4 +1,4 @@ -; Add support for (node:test, bun:test and Jest) runnable +; Add support for (node:test, bun:test, Jest and Deno.test) runnable ; Function expression that has `it`, `test` or `describe` as the function name ( (call_expression @@ -44,3 +44,42 @@ (#set! tag js-test) ) + +; Add support for Deno.test with string names +( + (call_expression + function: (member_expression + object: (identifier) @_namespace + property: (property_identifier) @_method + ) + (#eq? @_namespace "Deno") + (#eq? @_method "test") + arguments: ( + arguments . [ + (string (string_fragment) @run @DENO_TEST_NAME) + (identifier) @run @DENO_TEST_NAME + ] + ) + ) @_js-test + + (#set! tag js-test) +) + +; Add support for Deno.test with named function expressions +( + (call_expression + function: (member_expression + object: (identifier) @_namespace + property: (property_identifier) @_method + ) + (#eq? @_namespace "Deno") + (#eq? @_method "test") + arguments: ( + arguments . (function_expression + name: (identifier) @run @DENO_TEST_NAME + ) + ) + ) @_js-test + + (#set! tag js-test) +) diff --git a/docs/src/languages/deno.md b/docs/src/languages/deno.md index c18b112326..c40b6531e6 100644 --- a/docs/src/languages/deno.md +++ b/docs/src/languages/deno.md @@ -57,6 +57,40 @@ See [Configuring supported languages](../configuring-languages.md) in the Zed do TBD: Deno Typescript REPL instructions [docs/repl#typescript-deno](../repl.md#typescript-deno) --> +## DAP support + +To debug deno programs, add this to `.zed/debug.json` + +```json +[ + { + "adapter": "JavaScript", + "label": "Deno", + "request": "launch", + "type": "pwa-node", + "cwd": "$ZED_WORKTREE_ROOT", + "program": "$ZED_FILE", + "runtimeExecutable": "deno", + "runtimeArgs": ["run", "--allow-all", "--inspect-wait"], + "attachSimplePort": 9229 + } +] +``` + +## Runnable support + +To run deno tasks like tests from the ui, add this to `.zed/tasks.json` + +```json +[ + { + "label": "deno test", + "command": "deno test -A --filter '/^$ZED_CUSTOM_DENO_TEST_NAME$/' $ZED_FILE", + "tags": ["js-test"] + } +] +``` + ## See also: - [TypeScript](./typescript.md)