Improve runnable detection for JavaScript files (#21246)
Closes #21242   Release Notes: - Improved runnable detection for JavaScript/Typescript files.
This commit is contained in:
parent
66ba9d5b4b
commit
04ff9f060c
6 changed files with 79 additions and 34 deletions
|
@ -62,12 +62,20 @@
|
|||
name: (_) @name) @item
|
||||
|
||||
; Add support for (node:test, bun:test and Jest) runnable
|
||||
(call_expression
|
||||
function: (_) @context
|
||||
(#any-of? @context "it" "test" "describe")
|
||||
arguments: (
|
||||
arguments . (string
|
||||
(string_fragment) @name
|
||||
(
|
||||
(call_expression
|
||||
function: [
|
||||
(identifier) @_name
|
||||
(member_expression
|
||||
object: [
|
||||
(identifier) @_name
|
||||
(member_expression object: (identifier) @_name)
|
||||
]*
|
||||
)
|
||||
]* @context
|
||||
(#any-of? @_name "it" "test" "describe")
|
||||
arguments: (
|
||||
arguments . (string (string_fragment) @name)
|
||||
)
|
||||
)
|
||||
) @item
|
||||
|
|
|
@ -2,13 +2,20 @@
|
|||
; Function expression that has `it`, `test` or `describe` as the function name
|
||||
(
|
||||
(call_expression
|
||||
function: (_) @_name
|
||||
function: [
|
||||
(identifier) @_name
|
||||
(member_expression
|
||||
object: [
|
||||
(identifier) @_name
|
||||
(member_expression object: (identifier) @_name)
|
||||
]*
|
||||
)
|
||||
]
|
||||
(#any-of? @_name "it" "test" "describe")
|
||||
arguments: (
|
||||
arguments . (string
|
||||
(string_fragment) @run
|
||||
)
|
||||
arguments . (string (string_fragment) @run)
|
||||
)
|
||||
) @_js-test
|
||||
|
||||
(#set! tag js-test)
|
||||
)
|
||||
|
|
|
@ -70,12 +70,20 @@
|
|||
name: (_) @name) @item
|
||||
|
||||
; Add support for (node:test, bun:test and Jest) runnable
|
||||
(call_expression
|
||||
function: (_) @context
|
||||
(#any-of? @context "it" "test" "describe")
|
||||
arguments: (
|
||||
arguments . (string
|
||||
(string_fragment) @name
|
||||
(
|
||||
(call_expression
|
||||
function: [
|
||||
(identifier) @_name
|
||||
(member_expression
|
||||
object: [
|
||||
(identifier) @_name
|
||||
(member_expression object: (identifier) @_name)
|
||||
]*
|
||||
)
|
||||
]* @context
|
||||
(#any-of? @_name "it" "test" "describe")
|
||||
arguments: (
|
||||
arguments . (string (string_fragment) @name)
|
||||
)
|
||||
)
|
||||
) @item
|
||||
|
|
|
@ -2,13 +2,20 @@
|
|||
; Function expression that has `it`, `test` or `describe` as the function name
|
||||
(
|
||||
(call_expression
|
||||
function: (_) @_name
|
||||
function: [
|
||||
(identifier) @_name
|
||||
(member_expression
|
||||
object: [
|
||||
(identifier) @_name
|
||||
(member_expression object: (identifier) @_name)
|
||||
]*
|
||||
)
|
||||
]
|
||||
(#any-of? @_name "it" "test" "describe")
|
||||
arguments: (
|
||||
arguments . (string
|
||||
(string_fragment) @run
|
||||
)
|
||||
arguments . (string (string_fragment) @run)
|
||||
)
|
||||
) @_tsx-test
|
||||
(#set! tag tsx-test)
|
||||
) @_js-test
|
||||
|
||||
(#set! tag js-test)
|
||||
)
|
||||
|
|
|
@ -70,12 +70,20 @@
|
|||
name: (_) @name) @item
|
||||
|
||||
; Add support for (node:test, bun:test and Jest) runnable
|
||||
(call_expression
|
||||
function: (_) @context
|
||||
(#any-of? @context "it" "test" "describe")
|
||||
arguments: (
|
||||
arguments . (string
|
||||
(string_fragment) @name
|
||||
(
|
||||
(call_expression
|
||||
function: [
|
||||
(identifier) @_name
|
||||
(member_expression
|
||||
object: [
|
||||
(identifier) @_name
|
||||
(member_expression object: (identifier) @_name)
|
||||
]*
|
||||
)
|
||||
]* @context
|
||||
(#any-of? @_name "it" "test" "describe")
|
||||
arguments: (
|
||||
arguments . (string (string_fragment) @name)
|
||||
)
|
||||
)
|
||||
) @item
|
||||
|
|
|
@ -2,13 +2,20 @@
|
|||
; Function expression that has `it`, `test` or `describe` as the function name
|
||||
(
|
||||
(call_expression
|
||||
function: (_) @_name
|
||||
function: [
|
||||
(identifier) @_name
|
||||
(member_expression
|
||||
object: [
|
||||
(identifier) @_name
|
||||
(member_expression object: (identifier) @_name)
|
||||
]*
|
||||
)
|
||||
]
|
||||
(#any-of? @_name "it" "test" "describe")
|
||||
arguments: (
|
||||
arguments . (string
|
||||
(string_fragment) @run
|
||||
)
|
||||
arguments . (string (string_fragment) @run)
|
||||
)
|
||||
) @_ts-test
|
||||
(#set! tag ts-test)
|
||||
) @_js-test
|
||||
|
||||
(#set! tag js-test)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue