Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests/fixtures/sample_bun.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { describe, it, test, expect, beforeEach } from 'bun:test';
import { UserRepository, UserService } from './sample_typescript';

describe('UserService (bun)', () => {
let repo: UserRepository;

beforeEach(() => {
repo = new UserRepository();
});

it('constructs a service with a repository', () => {
const service = new UserService();
expect(service).toBeDefined();
});

it('finds a user by id', () => {
const service = new UserService();
const user = service.getUser(123);
expect(user).toBeUndefined();
});

test('creates a user via the service', () => {
const service = new UserService();
const created = service.createUser('alice', 'alice@example.com');
expect(created.name).toBe('alice');
});
});
23 changes: 23 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,29 @@ def test_vitest_tested_by_edges(self):
f"All edges: {[(e.kind, e.source, e.target) for e in edges]}"
)

# --- Bun test detection (regression: bun:test uses identical runner names) ---

def test_bun_test_detection(self):
"""A .test.ts file importing from 'bun:test' should produce Test nodes."""
nodes, _ = self.parser.parse_file(FIXTURES / "sample_bun.test.ts")
tests = [n for n in nodes if n.kind == "Test"]
test_names = {t.name for t in tests}
assert any(n.startswith("describe") or n.startswith("describe:") for n in test_names), (
f"Expected describe Test node, got: {test_names}"
)
assert any(n.startswith("it:") or n.startswith("test:") for n in test_names), (
f"Expected it/test Test node, got: {test_names}"
)

def test_bun_tested_by_edges(self):
"""TESTED_BY edges should be generated from bun tests to production code."""
_, edges = self.parser.parse_file(FIXTURES / "sample_bun.test.ts")
tested_by = [e for e in edges if e.kind == "TESTED_BY"]
assert len(tested_by) >= 1, (
Comment on lines +665 to +669
f"Expected TESTED_BY edges, got none. "
f"All edges: {[(e.kind, e.source, e.target) for e in edges]}"
)

def test_non_test_file_describe_not_special(self):
"""describe() in a non-test file should NOT create Test nodes."""
import tempfile
Expand Down
Loading