History

Added TSX test runnables (#12922)

Fix #12884 Release Notes: - Added runnable tests for TSX files. --- Runnable tests can be customized via `tsx-test` tag ---------

Chung Wei Leong committed 2 years ago

Commit ec95a331 parent b8235093 files · +17 −2Browse files

Unified · Split

3 files
  1. crates/languages/src/lib.rs +2 −1
  2. crates/languages/src/tsx/runnables.scm +14 −0
  3. crates/languages/src/typescript.rs +1 −1
crates/languages/src/lib.rs+2−1
@@ -141,7 +141,8 @@ pub fn init( · 140 unmodified lines
141141 vec![
142142 Arc::new(typescript::TypeScriptLspAdapter::new(node_runtime.clone())),
143143 Arc::new(vtsls::VtslsLspAdapter::new(node_runtime.clone()))
144− ]
144+ ],
145+ typescript_task_context()
145146 );
146147 language!(
147148 "typescript",
crates/languages/src/tsx/runnables.scm+14−0
@@ -0,0 +1,14 @@
1+; Add support for (node:test, bun:test and Jest) runnable
2+; Function expression that has `it`, `test` or `describe` as the function name
3+(
4+ (call_expression
5+ function: (_) @_name
6+ (#any-of? @_name "it" "test" "describe")
7+ arguments: (
8+ arguments . (string
9+ (string_fragment) @run
10+ )
11+ )
12+ ) @_tsx-test
13+ (#set! tag tsx-test)
14+)
crates/languages/src/typescript.rs+1−1
@@ -37,7 +37,7 @@ pub(super) fn typescript_task_context() -> ContextProviderWithTasks { · 36 unmodified lines
3737 VariableName::Symbol.template_value(),
3838 VariableName::File.template_value(),
3939 ],
40− tags: vec!["ts-test".into(), "js-test".into()],
40+ tags: vec!["ts-test".into(), "js-test".into(), "tsx-test".into()],
4141 ..TaskTemplate::default()
4242 },
4343 TaskTemplate {