Skip to content
Merged
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
10 changes: 5 additions & 5 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ async function runSingleTest(
console.log(`\n[${testIndex + 1}/${totalTests}] Running test: ${test.name}`);
console.log("─".repeat(50));

const prompt = buildAgentPrompt(test);
const fullPrompt = buildAgentPrompt(test);

try {
const tools = {
Expand Down Expand Up @@ -301,15 +301,15 @@ async function runSingleTest(
if (testComponentEnabled) {
console.log(" 📋 TestComponent tool is available");
}
const result = await agent.generate({ prompt });
const result = await agent.generate({ prompt: fullPrompt });

const resultWriteContent = extractResultWriteContent(result.steps);

if (!resultWriteContent) {
console.log(" ⚠️ No ResultWrite output found");
return {
testName: test.name,
prompt: test.prompt,
prompt: fullPrompt,
steps: result.steps as unknown as SingleTestResult["steps"],
resultWriteContent: null,
verification: null,
Expand Down Expand Up @@ -340,7 +340,7 @@ async function runSingleTest(

return {
testName: test.name,
prompt: test.prompt,
prompt: fullPrompt,
steps: result.steps as unknown as SingleTestResult["steps"],
resultWriteContent,
verification,
Expand All @@ -349,7 +349,7 @@ async function runSingleTest(
console.error(`✗ Error running test: ${error}`);
return {
testName: test.name,
prompt: test.prompt,
prompt: fullPrompt,
steps: [],
resultWriteContent: null,
verification: {
Expand Down
17 changes: 14 additions & 3 deletions lib/test-discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ export interface TestDefinition {
testFile: string;
promptFile: string;
prompt: string;
testContent: string;
}

export function discoverTests() {
export function discoverTests(): TestDefinition[] {
const testsDir = join(process.cwd(), "tests");
const definitions = [];
const definitions: TestDefinition[] = [];

try {
const entries = readdirSync(testsDir);
Expand All @@ -34,6 +35,7 @@ export function discoverTests() {
existsSync(promptFile)
) {
const prompt = readFileSync(promptFile, "utf-8");
const testContent = readFileSync(testFile, "utf-8");

definitions.push({
name: entry,
Expand All @@ -43,6 +45,7 @@ export function discoverTests() {
testFile,
promptFile,
prompt,
testContent,
});
} else {
const missing = [];
Expand All @@ -62,8 +65,16 @@ export function discoverTests() {
return definitions;
}

export function buildAgentPrompt(test: TestDefinition) {
export function buildAgentPrompt(test: TestDefinition): string {
return `${test.prompt}

## Test Suite

Your component must pass the following tests:

\`\`\`ts
${test.testContent}
\`\`\`

IMPORTANT: When you have finished implementing the component, use the ResultWrite tool to output your final Svelte component code. Only output the component code itself, no explanations or markdown formatting.`;
}
Loading