DocsSupported Languages

Supported Languages

testgap uses tree-sitter grammars to parse source code. Each language has specific patterns for detecting test functions and visibility.

Overview#

LanguageExtensionsTest Detection
Rust.rs#[test] attribute on functions
TypeScript.ts, .tsx, .mts, .ctstest() and it() function calls
JavaScript.js, .jsx, .mjs, .cjstest() and it() function calls
Python.pytest_ prefix on function names
Go.goTest prefix on function names (TestXxx)

Rust#

Extensions

.rs

Test Detection

  • #[test] attribute on functions
  • #[cfg(test)] module attribute
  • test_ prefix on function names

Visibility

pub keyword on fn declarations. Supports pub(crate), pub(super) variants.

Example Test

example test
#[test]
fn test_process_payment() {
    let order = Order::new();
    let result = process_payment(&order, PaymentMethod::Card);
    assert!(result.is_ok());
}

TypeScript#

Extensions

.ts, .tsx, .mts, .cts

Test Detection

  • test() and it() function calls
  • describe() blocks
  • Files in __tests__/ directories
  • Files matching *.test.ts, *.spec.ts

Visibility

export keyword on function/const declarations. Default exports detected.

Example Test

example test
describe('processPayment', () => {
  it('should process valid payment', () => {
    const result = processPayment(order, 'card');
    expect(result.success).toBe(true);
  });
});

JavaScript#

Extensions

.js, .jsx, .mjs, .cjs

Test Detection

  • test() and it() function calls
  • describe() blocks
  • Files in __tests__/ directories
  • Files matching *.test.js, *.spec.js

Visibility

export/module.exports detection. Named and default exports.

Example Test

example test
test('processPayment handles card', () => {
  const result = processPayment(order, 'card');
  expect(result.success).toBe(true);
});

Python#

Extensions

.py

Test Detection

  • test_ prefix on function names
  • Files in test/ or tests/ directories
  • Files matching test_*.py, *_test.py

Visibility

Functions without leading underscore are considered public. _private and __dunder detected.

Example Test

example test
def test_process_payment():
    order = Order()
    result = process_payment(order, "card")
    assert result.success

Go#

Extensions

.go

Test Detection

  • Test prefix on function names (TestXxx)
  • *testing.T parameter
  • Files matching *_test.go

Visibility

Uppercase first letter = exported (public). Lowercase = unexported (private).

Example Test

example test
func TestProcessPayment(t *testing.T) {
    order := NewOrder()
    result, err := ProcessPayment(order, "card")
    if err != nil {
        t.Fatalf("unexpected error: %v", err)
    }
}

Adding a language

Want support for another language? See the Contributing Guide for instructions on adding a new tree-sitter grammar.