Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for call expressions in a test case #120

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lua/neotest-jest/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function adapter.discover_positions(path)
; Matches: `describe('context', () => {})`
((call_expression
function: (identifier) @func_name (#eq? @func_name "describe")
arguments: (arguments (string (string_fragment) @namespace.name) (arrow_function))
arguments: (arguments (string (string_fragment) @namespace.name) [(arrow_function)])
)) @namespace.definition
; Matches: `describe('context', function() {})`
((call_expression
Expand All @@ -177,7 +177,7 @@ function adapter.discover_positions(path)
function: (member_expression
object: (identifier) @func_name (#any-of? @func_name "describe")
)
arguments: (arguments (string (string_fragment) @namespace.name) (arrow_function))
arguments: (arguments (string (string_fragment) @namespace.name) [(arrow_function)])
)) @namespace.definition
; Matches: `describe.only('context', function() {})`
((call_expression
Expand All @@ -193,7 +193,7 @@ function adapter.discover_positions(path)
object: (identifier) @func_name (#any-of? @func_name "describe")
)
)
arguments: (arguments (string (string_fragment) @namespace.name) (arrow_function))
arguments: (arguments (string (string_fragment) @namespace.name) [(arrow_function)])
)) @namespace.definition
; Matches: `describe.each(['data'])('context', function() {})`
((call_expression
Expand All @@ -209,14 +209,14 @@ function adapter.discover_positions(path)
; Matches: `test('test') / it('test')`
((call_expression
function: (identifier) @func_name (#any-of? @func_name "it" "test")
arguments: (arguments (string (string_fragment) @test.name) [(arrow_function) (function_expression)])
arguments: (arguments (string (string_fragment) @test.name) [(arrow_function) (function_expression) (call_expression)])
)) @test.definition
; Matches: `test.only('test') / it.only('test')`
((call_expression
function: (member_expression
object: (identifier) @func_name (#any-of? @func_name "test" "it")
)
arguments: (arguments (string (string_fragment) @test.name) [(arrow_function) (function_expression)])
arguments: (arguments (string (string_fragment) @test.name) [(arrow_function) (function_expression) (call_expression)])
)) @test.definition
; Matches: `test.each(['data'])('test') / it.each(['data'])('test')`
((call_expression
Expand All @@ -226,7 +226,7 @@ function adapter.discover_positions(path)
property: (property_identifier) @each_property (#eq? @each_property "each")
)
)
arguments: (arguments (string (string_fragment) @test.name) [(arrow_function) (function_expression)])
arguments: (arguments (string (string_fragment) @test.name) [(arrow_function) (function_expression) (call_expression)])
)) @test.definition
]]

Expand Down