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#
| Language | Extensions | Test Detection |
|---|---|---|
| Rust | .rs | #[test] attribute on functions |
| TypeScript | .ts, .tsx, .mts, .cts | test() and it() function calls |
| JavaScript | .js, .jsx, .mjs, .cjs | test() and it() function calls |
| Python | .py | test_ prefix on function names |
| Go | .go | Test 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
#[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
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
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
def test_process_payment():
order = Order()
result = process_payment(order, "card")
assert result.successGo#
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
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.