From 08be27cb2f0dcd56d59d738b106617940af673ab Mon Sep 17 00:00:00 2001 From: Dennis van den Berg Date: Tue, 7 May 2024 09:47:05 +0200 Subject: [PATCH] feat: add support for call expressions in a test case --- lua/neotest-jest/init.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lua/neotest-jest/init.lua b/lua/neotest-jest/init.lua index a199bb7..410b86e 100644 --- a/lua/neotest-jest/init.lua +++ b/lua/neotest-jest/init.lua @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 ]]