Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Added TSX test runnables (#12922)

Chung Wei Leongec95a33d8cfc
diff --git a/crates/languages/src/lib.rs b/crates/languages/src/lib.rs
index f2860f24953..9ca727f46e6 100644
--- a/crates/languages/src/lib.rs
+++ b/crates/languages/src/lib.rs
@@ -141,7 +141,8 @@ pub fn init(
vec![
Arc::new(typescript::TypeScriptLspAdapter::new(node_runtime.clone())),
Arc::new(vtsls::VtslsLspAdapter::new(node_runtime.clone()))
- ]
+ ],
+ typescript_task_context()
);
language!(
"typescript",
diff --git a/crates/languages/src/tsx/runnables.scm b/crates/languages/src/tsx/runnables.scm
new file mode 100644
index 00000000000..68c81d04c78
--- /dev/null
+++ b/crates/languages/src/tsx/runnables.scm
@@ -0,0 +1,14 @@
+; Add support for (node:test, bun:test and Jest) runnable
+; Function expression that has `it`, `test` or `describe` as the function name
+(
+ (call_expression
+ function: (_) @_name
+ (#any-of? @_name "it" "test" "describe")
+ arguments: (
+ arguments . (string
+ (string_fragment) @run
+ )
+ )
+ ) @_tsx-test
+ (#set! tag tsx-test)
+)
diff --git a/crates/languages/src/typescript.rs b/crates/languages/src/typescript.rs
index 72ec30b03f3..e59bd516380 100644
--- a/crates/languages/src/typescript.rs
+++ b/crates/languages/src/typescript.rs
@@ -37,7 +37,7 @@ pub(super) fn typescript_task_context() -> ContextProviderWithTasks {
VariableName::Symbol.template_value(),
VariableName::File.template_value(),
],
- tags: vec!["ts-test".into(), "js-test".into()],
+ tags: vec!["ts-test".into(), "js-test".into(), "tsx-test".into()],
..TaskTemplate::default()
},
TaskTemplate {