From 6ea51a1b9fd65c36f58729267b4a9abd992d05a4 Mon Sep 17 00:00:00 2001 From: Jordan Faust Date: Thu, 15 Feb 2024 20:21:49 -0600 Subject: [PATCH] fix: fix javascript treesitter queries BREAKING_CHANGE: switch to the new (function_expression) pattern that replaces the previous (function). This will be a breaking change for anyone on v0.9.1 or earlier of treesitter --- 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 8d9a656..7cea58c 100644 --- a/lua/neotest-jest/init.lua +++ b/lua/neotest-jest/init.lua @@ -162,7 +162,7 @@ function adapter.discover_positions(path) ; Matches: `describe('context', function() {})` ((call_expression function: (identifier) @func_name (#eq? @func_name "describe") - arguments: (arguments (string (string_fragment) @namespace.name) (function)) + arguments: (arguments (string (string_fragment) @namespace.name) (function_expression)) )) @namespace.definition ; Matches: `describe.only('context', () => {})` ((call_expression @@ -176,7 +176,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) (function)) + arguments: (arguments (string (string_fragment) @namespace.name) (function_expression)) )) @namespace.definition ; Matches: `describe.each(['data'])('context', () => {})` ((call_expression @@ -194,21 +194,21 @@ function adapter.discover_positions(path) object: (identifier) @func_name (#any-of? @func_name "describe") ) ) - arguments: (arguments (string (string_fragment) @namespace.name) (function)) + arguments: (arguments (string (string_fragment) @namespace.name) (function_expression)) )) @namespace.definition ; -- Tests -- ; 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)]) + arguments: (arguments (string (string_fragment) @test.name) [(arrow_function) (function_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)]) + arguments: (arguments (string (string_fragment) @test.name) [(arrow_function) (function_expression)]) )) @test.definition ; Matches: `test.each(['data'])('test') / it.each(['data'])('test')` ((call_expression @@ -218,7 +218,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)]) + arguments: (arguments (string (string_fragment) @test.name) [(arrow_function) (function_expression)]) )) @test.definition ]]