-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathassertion.test.ts
More file actions
49 lines (43 loc) · 1.82 KB
/
Copy pathassertion.test.ts
File metadata and controls
49 lines (43 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { describe, expect, it } from 'bun:test';
import { mkdtemp, readFile, rm, symlink } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { execa } from 'execa';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const projectRoot = path.resolve(__dirname, '../../../../..');
const CLI_ENTRY = path.join(projectRoot, 'apps/cli/src/cli.ts');
describe('agentv create assertion', () => {
it('scaffolds canonical assertion output without deprecated reasoning examples', async () => {
const cwd = await mkdtemp(path.join(tmpdir(), 'agentv-create-assertion-'));
try {
await symlink(
path.join(projectRoot, 'node_modules'),
path.join(cwd, 'node_modules'),
process.platform === 'win32' ? 'junction' : 'dir',
);
const result = await execa(
'bun',
['--no-env-file', CLI_ENTRY, 'create', 'assertion', 'word-count'],
{ cwd, reject: false },
);
expect(result.exitCode).toBe(0);
const content = await readFile(
path.join(cwd, '.agentv', 'assertions', 'word-count.ts'),
'utf8',
);
expect(content).toContain("import { defineAssertion } from '@agentv/sdk';");
expect(content).toContain("const text = output ?? '';");
expect(content).toContain('pass,');
expect(content).toContain('score: pass ? 1 : 0,');
expect(content).toContain("reason: pass ? 'Output has content' : 'Output is empty'");
expect(content).not.toContain('assertions:');
expect(content).not.toContain('passed:');
expect(content).not.toContain('reasoning:');
expect(content).not.toContain('getMessageText');
} finally {
await rm(cwd, { recursive: true, force: true });
}
}, 30_000);
});