feat: add test declarations support in typescript tree-sitter queries (#1899)

Add parsing support for:
- Jest describe/test/it blocks
- npm test exports

This enables proper identification of test definitions in TypeScript files:

```
// File: multi-search-replace.test.ts (192 definitions)
│| 2 - 1565 ||describe("MultiSearchReplaceDiffStrategy", () => {
│| 3 - 632 ||	describe("exact matching", () => {
│| 10 - 28 ||		it("should replace matching content", async () => {
||    ||----
│| 30 - 48 ||		it("should match content with different surrounding whitespace", async () => {
||    ||----
│| 50 - 68 ||		it("should match content with different indentation in search block", async () => {
||    ||----
│| 70 - 88 ||		it("should handle tab-based indentation", async () => {
||    ||----
```

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
Co-authored-by: Eric Wheeler <roo-code@z.ewheeler.org>
This commit is contained in:
KJ7LNW 2025-03-24 10:32:18 -07:00 committed by GitHub
parent 15338ed76a
commit 187979af2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -29,4 +29,19 @@ export default `
(class_declaration
name: (type_identifier) @name.definition.class) @definition.class
(call_expression
function: (identifier) @func_name
arguments: (arguments
(string) @name
[(arrow_function) (function_expression)]) @definition.test)
(#match? @func_name "^(describe|test|it)$")
(assignment_expression
left: (member_expression
object: (identifier) @obj
property: (property_identifier) @prop)
right: [(arrow_function) (function_expression)]) @definition.test
(#eq? @obj "exports")
(#eq? @prop "test")
`