@voltade/mastra-unit-test 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +129 -0
- package/dist/cli.js.map +1 -0
- package/dist/discovery.d.ts +14 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +158 -0
- package/dist/discovery.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/runner.d.ts +38 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +376 -0
- package/dist/runner.js.map +1 -0
- package/dist/types.d.ts +130 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/AgentList.d.ts +7 -0
- package/dist/ui/AgentList.d.ts.map +1 -0
- package/dist/ui/AgentList.js +11 -0
- package/dist/ui/AgentList.js.map +1 -0
- package/dist/ui/TestRunner.d.ts +15 -0
- package/dist/ui/TestRunner.d.ts.map +1 -0
- package/dist/ui/TestRunner.js +79 -0
- package/dist/ui/TestRunner.js.map +1 -0
- package/dist/ui/index.d.ts +3 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +3 -0
- package/dist/ui/index.js.map +1 -0
- package/package.json +62 -0
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.tsx"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { render } from 'ink';
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
import { TestRunnerUI } from './ui/TestRunner.js';
|
|
7
|
+
import { AgentListUI } from './ui/AgentList.js';
|
|
8
|
+
import { discoverAgents, discoverTestFiles, loadTestSuites } from './discovery.js';
|
|
9
|
+
const program = new Command();
|
|
10
|
+
program
|
|
11
|
+
.name('mastra-test')
|
|
12
|
+
.description('Unit testing framework for Mastra AI agents')
|
|
13
|
+
.version('0.1.0');
|
|
14
|
+
program
|
|
15
|
+
.command('run')
|
|
16
|
+
.description('Run agent tests')
|
|
17
|
+
.option('-p, --path <path>', 'Path to Mastra project', process.cwd())
|
|
18
|
+
.option('-a, --agent <name>', 'Run tests for specific agent only')
|
|
19
|
+
.option('-t, --tags <tags>', 'Filter tests by tags (comma-separated)')
|
|
20
|
+
.option('--pattern <pattern>', 'Test file pattern', '**/*.mastra-test.ts')
|
|
21
|
+
.option('--timeout <ms>', 'Default test timeout in milliseconds', '30000')
|
|
22
|
+
.option('--parallel', 'Run tests in parallel', false)
|
|
23
|
+
.option('-v, --verbose', 'Verbose output', false)
|
|
24
|
+
.action(async (options) => {
|
|
25
|
+
const projectRoot = path.resolve(options.path);
|
|
26
|
+
try {
|
|
27
|
+
// Discover test files first
|
|
28
|
+
const testFiles = await discoverTestFiles(projectRoot, options.pattern);
|
|
29
|
+
const suites = await loadTestSuites(testFiles);
|
|
30
|
+
let exitCode = 0;
|
|
31
|
+
const handleComplete = (summary) => {
|
|
32
|
+
exitCode = summary.failed > 0 || summary.timeout > 0 ? 1 : 0;
|
|
33
|
+
};
|
|
34
|
+
const { waitUntilExit } = render(_jsx(TestRunnerUI, { projectRoot: projectRoot, testPattern: options.pattern, agent: options.agent, tags: options.tags ? options.tags.split(',') : undefined, timeout: parseInt(options.timeout, 10), parallel: options.parallel, verbose: options.verbose, suites: suites, onComplete: handleComplete }));
|
|
35
|
+
await waitUntilExit();
|
|
36
|
+
process.exit(exitCode);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error('Error running tests:', error);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
program
|
|
44
|
+
.command('agents')
|
|
45
|
+
.description('List discovered agents in the Mastra project')
|
|
46
|
+
.option('-p, --path <path>', 'Path to Mastra project', process.cwd())
|
|
47
|
+
.action(async (options) => {
|
|
48
|
+
const projectRoot = path.resolve(options.path);
|
|
49
|
+
try {
|
|
50
|
+
const agents = await discoverAgents(projectRoot);
|
|
51
|
+
const { waitUntilExit } = render(_jsx(AgentListUI, { agents: agents }));
|
|
52
|
+
await waitUntilExit();
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
console.error('Error discovering agents:', error);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
program
|
|
60
|
+
.command('init')
|
|
61
|
+
.description('Initialize test structure in current project')
|
|
62
|
+
.option('-p, --path <path>', 'Path to Mastra project', process.cwd())
|
|
63
|
+
.action(async (options) => {
|
|
64
|
+
const projectRoot = path.resolve(options.path);
|
|
65
|
+
const fs = await import('fs/promises');
|
|
66
|
+
// Create tests directory
|
|
67
|
+
const testsDir = path.join(projectRoot, 'tests');
|
|
68
|
+
try {
|
|
69
|
+
await fs.mkdir(testsDir, { recursive: true });
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
// Directory might already exist
|
|
73
|
+
}
|
|
74
|
+
// Create example test file
|
|
75
|
+
const exampleTest = `import type { AgentTestSuite } from '@voltade/mastra-test';
|
|
76
|
+
|
|
77
|
+
// Example test suite for an agent
|
|
78
|
+
export const tests: AgentTestSuite = {
|
|
79
|
+
agent: 'my-agent', // Replace with your agent name
|
|
80
|
+
description: 'Tests for my-agent',
|
|
81
|
+
tests: [
|
|
82
|
+
{
|
|
83
|
+
name: 'should respond to greeting',
|
|
84
|
+
input: 'Hello!',
|
|
85
|
+
expect: {
|
|
86
|
+
contains: 'hello', // Case-insensitive
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'should not contain profanity',
|
|
91
|
+
input: 'Tell me a joke',
|
|
92
|
+
expect: {
|
|
93
|
+
notContains: ['inappropriate', 'offensive'],
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'should call weather tool',
|
|
98
|
+
input: 'What is the weather in Tokyo?',
|
|
99
|
+
expect: {
|
|
100
|
+
toolCalls: [{ name: 'getWeather' }],
|
|
101
|
+
contains: 'tokyo',
|
|
102
|
+
},
|
|
103
|
+
tags: ['weather', 'tools'],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'should pass custom validation',
|
|
107
|
+
input: 'Generate a short response',
|
|
108
|
+
expect: {
|
|
109
|
+
validate: (output) => output.length < 500,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export default tests;
|
|
116
|
+
`;
|
|
117
|
+
const examplePath = path.join(testsDir, 'example.mastra-test.ts');
|
|
118
|
+
await fs.writeFile(examplePath, exampleTest);
|
|
119
|
+
console.log('');
|
|
120
|
+
console.log('\x1b[32m✓\x1b[0m Created tests directory at', testsDir);
|
|
121
|
+
console.log('\x1b[32m✓\x1b[0m Created example test file at', examplePath);
|
|
122
|
+
console.log('');
|
|
123
|
+
console.log('\x1b[1mNext steps:\x1b[0m');
|
|
124
|
+
console.log(' 1. Edit the example test file with your agent name');
|
|
125
|
+
console.log(' 2. Run tests with: mastra-test run');
|
|
126
|
+
console.log('');
|
|
127
|
+
});
|
|
128
|
+
program.parse();
|
|
129
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.tsx"],"names":[],"mappings":";;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AAC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AAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,6CAA6C,EAAE,QAAQ,CAAC,CAAC;IACrE,OAAO,CAAC,GAAG,CAAC,+CAA+C,EAAE,WAAW,CAAC,CAAC;IAC1E,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IACzC,OAAO,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAC;IACpE,OAAO,CAAC,GAAG,CAAC,sCAAsC,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AgentTestSuite, DiscoveredAgent } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Discovers test files in the project
|
|
4
|
+
*/
|
|
5
|
+
export declare function discoverTestFiles(projectRoot: string, pattern?: string): Promise<string[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Loads test suites from discovered test files
|
|
8
|
+
*/
|
|
9
|
+
export declare function loadTestSuites(testFiles: string[]): Promise<AgentTestSuite[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Discovers agents from a Mastra project
|
|
12
|
+
*/
|
|
13
|
+
export declare function discoverAgents(projectRoot: string): Promise<DiscoveredAgent[]>;
|
|
14
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElE;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,MAA8B,GACtC,OAAO,CAAC,MAAM,EAAE,CAAC,CAOnB;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC,cAAc,EAAE,CAAC,CA8B3B;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,eAAe,EAAE,CAAC,CA4D5B"}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { glob } from 'glob';
|
|
2
|
+
import { pathToFileURL } from 'url';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
/**
|
|
5
|
+
* Discovers test files in the project
|
|
6
|
+
*/
|
|
7
|
+
export async function discoverTestFiles(projectRoot, pattern = '**/*.mastra-test.ts') {
|
|
8
|
+
const files = await glob(pattern, {
|
|
9
|
+
cwd: projectRoot,
|
|
10
|
+
absolute: true,
|
|
11
|
+
ignore: ['node_modules/**', 'dist/**'],
|
|
12
|
+
});
|
|
13
|
+
return files;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Loads test suites from discovered test files
|
|
17
|
+
*/
|
|
18
|
+
export async function loadTestSuites(testFiles) {
|
|
19
|
+
const suites = [];
|
|
20
|
+
for (const file of testFiles) {
|
|
21
|
+
try {
|
|
22
|
+
const fileUrl = pathToFileURL(file).href;
|
|
23
|
+
const module = await import(fileUrl);
|
|
24
|
+
// Look for default export or named 'tests' export
|
|
25
|
+
if (module.default) {
|
|
26
|
+
if (Array.isArray(module.default)) {
|
|
27
|
+
suites.push(...module.default);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
suites.push(module.default);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (module.tests) {
|
|
34
|
+
if (Array.isArray(module.tests)) {
|
|
35
|
+
suites.push(...module.tests);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
suites.push(module.tests);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.error(`Failed to load test file: ${file}`, error);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return suites;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Discovers agents from a Mastra project
|
|
50
|
+
*/
|
|
51
|
+
export async function discoverAgents(projectRoot) {
|
|
52
|
+
const agents = [];
|
|
53
|
+
// Try to find the Mastra entry point
|
|
54
|
+
const possiblePaths = [
|
|
55
|
+
path.join(projectRoot, 'src', 'mastra', 'index.ts'),
|
|
56
|
+
path.join(projectRoot, 'src', 'mastra', 'index.js'),
|
|
57
|
+
path.join(projectRoot, 'mastra', 'index.ts'),
|
|
58
|
+
path.join(projectRoot, 'mastra', 'index.js'),
|
|
59
|
+
];
|
|
60
|
+
let mastraModule = null;
|
|
61
|
+
for (const mastraPath of possiblePaths) {
|
|
62
|
+
try {
|
|
63
|
+
const fileUrl = pathToFileURL(mastraPath).href;
|
|
64
|
+
mastraModule = await import(fileUrl);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// Try next path
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (!mastraModule) {
|
|
72
|
+
// Try to find agent files directly
|
|
73
|
+
const agentFiles = await glob('**/agents/**/*.ts', {
|
|
74
|
+
cwd: projectRoot,
|
|
75
|
+
absolute: true,
|
|
76
|
+
ignore: ['node_modules/**', 'dist/**', '**/*.test.ts', '**/*.spec.ts'],
|
|
77
|
+
});
|
|
78
|
+
for (const file of agentFiles) {
|
|
79
|
+
try {
|
|
80
|
+
const fileUrl = pathToFileURL(file).href;
|
|
81
|
+
const module = await import(fileUrl);
|
|
82
|
+
// Look for Agent instances
|
|
83
|
+
for (const [key, value] of Object.entries(module)) {
|
|
84
|
+
if (isAgent(value)) {
|
|
85
|
+
agents.push(extractAgentInfo(key, value));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// Skip files that can't be loaded
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
// Extract agents from Mastra instance or exports
|
|
96
|
+
for (const [key, value] of Object.entries(mastraModule)) {
|
|
97
|
+
if (isAgent(value)) {
|
|
98
|
+
agents.push(extractAgentInfo(key, value));
|
|
99
|
+
}
|
|
100
|
+
else if (isMastraInstance(value)) {
|
|
101
|
+
// If it's a Mastra instance, try to get agents from it
|
|
102
|
+
const mastraAgents = await getAgentsFromMastra(value);
|
|
103
|
+
agents.push(...mastraAgents);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return agents;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Type guard to check if value looks like a Mastra Agent
|
|
111
|
+
*/
|
|
112
|
+
function isAgent(value) {
|
|
113
|
+
if (!value || typeof value !== 'object')
|
|
114
|
+
return false;
|
|
115
|
+
const obj = value;
|
|
116
|
+
// Agent instances typically have these properties
|
|
117
|
+
return (('name' in obj || 'id' in obj) &&
|
|
118
|
+
('instructions' in obj || 'model' in obj || 'generate' in obj));
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Type guard to check if value is a Mastra instance
|
|
122
|
+
*/
|
|
123
|
+
function isMastraInstance(value) {
|
|
124
|
+
if (!value || typeof value !== 'object')
|
|
125
|
+
return false;
|
|
126
|
+
const obj = value;
|
|
127
|
+
return typeof obj.getAgent === 'function' || 'agents' in obj;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Extract agent info from Mastra instance
|
|
131
|
+
*/
|
|
132
|
+
async function getAgentsFromMastra(mastra) {
|
|
133
|
+
const agents = [];
|
|
134
|
+
if (mastra.agents && typeof mastra.agents === 'object') {
|
|
135
|
+
for (const [name, agent] of Object.entries(mastra.agents)) {
|
|
136
|
+
if (isAgent(agent)) {
|
|
137
|
+
agents.push(extractAgentInfo(name, agent));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return agents;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Extract agent information for display
|
|
145
|
+
*/
|
|
146
|
+
function extractAgentInfo(name, agent) {
|
|
147
|
+
const info = {
|
|
148
|
+
name: agent.name || agent.id || name,
|
|
149
|
+
};
|
|
150
|
+
if (typeof agent.instructions === 'string') {
|
|
151
|
+
info.instructions = agent.instructions.slice(0, 200);
|
|
152
|
+
}
|
|
153
|
+
if (agent.tools && typeof agent.tools === 'object') {
|
|
154
|
+
info.tools = Object.keys(agent.tools);
|
|
155
|
+
}
|
|
156
|
+
return info;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,WAAmB,EACnB,UAAkB,qBAAqB;IAEvC,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE;QAChC,GAAG,EAAE,WAAW;QAChB,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE,CAAC,iBAAiB,EAAE,SAAS,CAAC;KACvC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,SAAmB;IAEnB,MAAM,MAAM,GAAqB,EAAE,CAAC;IAEpC,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;QAC7B,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC;YACzC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;YAErC,kDAAkD;YAClD,IAAI,MAAM,CAAC,OAAO,EAAE,C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YACF,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACnB,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB,CACvB,IAAY,EACZ,KAA8B;IAE9B,MAAM,IAAI,GAAoB;QAC5B,IAAI,EAAG,KAAK,CAAC,IAAe,IAAK,KAAK,CAAC,EAAa,IAAI,IAAI;KAC7D,CAAC;IAEF,IAAI,OAAO,KAAK,CAAC,YAAY,KAAK,QAAQ,EAAE,CAAC;QAC3C,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,KAAK,CAAC,KAAK,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QACnD,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAgC,CAAC,CAAC;IACnE,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { TestCase, TestExpectation, ExpectedToolCall, AgentTestSuite, TestResult, TestRunSummary, TestRunnerConfig, DiscoveredAgent, } from './types.js';
|
|
2
|
+
export { TestRunner } from './runner.js';
|
|
3
|
+
export { discoverTestFiles, loadTestSuites, discoverAgents, } from './discovery.js';
|
|
4
|
+
export { TestRunnerUI } from './ui/TestRunner.js';
|
|
5
|
+
export { AgentListUI } from './ui/AgentList.js';
|
|
6
|
+
export declare function defineTests(suite: import('./types.js').AgentTestSuite): import('./types.js').AgentTestSuite;
|
|
7
|
+
export declare function defineTestSuites(suites: import('./types.js').AgentTestSuite[]): import('./types.js').AgentTestSuite[];
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,eAAe,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,GACf,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,YAAY,EAAE,cAAc,GAAG,OAAO,YAAY,EAAE,cAAc,CAE3G;AAGD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,YAAY,EAAE,cAAc,EAAE,GAAG,OAAO,YAAY,EAAE,cAAc,EAAE,CAErH"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Main exports for @voltade/mastra-test
|
|
2
|
+
// Core classes
|
|
3
|
+
export { TestRunner } from './runner.js';
|
|
4
|
+
// Discovery utilities
|
|
5
|
+
export { discoverTestFiles, loadTestSuites, discoverAgents, } from './discovery.js';
|
|
6
|
+
// UI Components (for custom integrations)
|
|
7
|
+
export { TestRunnerUI } from './ui/TestRunner.js';
|
|
8
|
+
export { AgentListUI } from './ui/AgentList.js';
|
|
9
|
+
// Helper function to define test suites with type safety
|
|
10
|
+
export function defineTests(suite) {
|
|
11
|
+
return suite;
|
|
12
|
+
}
|
|
13
|
+
// Helper function to define multiple test suites
|
|
14
|
+
export function defineTestSuites(suites) {
|
|
15
|
+
return suites;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAcxC,eAAe;AACf,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,sBAAsB;AACtB,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,GACf,MAAM,gBAAgB,CAAC;AAExB,0CAA0C;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,yDAAyD;AACzD,MAAM,UAAU,WAAW,CAAC,KAA0C;IACpE,OAAO,KAAK,CAAC;AACf,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,gBAAgB,CAAC,MAA6C;IAC5E,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/runner.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { TestRunSummary, TestRunnerConfig } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Main test runner for Mastra agents
|
|
4
|
+
*/
|
|
5
|
+
export declare class TestRunner {
|
|
6
|
+
private config;
|
|
7
|
+
private mastraInstance;
|
|
8
|
+
constructor(config: TestRunnerConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Initialize the runner and load Mastra
|
|
11
|
+
*/
|
|
12
|
+
initialize(): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Run all discovered tests
|
|
15
|
+
*/
|
|
16
|
+
run(): Promise<TestRunSummary>;
|
|
17
|
+
/**
|
|
18
|
+
* Run a single test suite
|
|
19
|
+
*/
|
|
20
|
+
private runSuite;
|
|
21
|
+
/**
|
|
22
|
+
* Run a single test case
|
|
23
|
+
*/
|
|
24
|
+
private runTest;
|
|
25
|
+
/**
|
|
26
|
+
* Execute an agent with the given input
|
|
27
|
+
*/
|
|
28
|
+
private executeAgent;
|
|
29
|
+
/**
|
|
30
|
+
* Validate test expectations against output
|
|
31
|
+
*/
|
|
32
|
+
private validateExpectations;
|
|
33
|
+
/**
|
|
34
|
+
* Get an agent by name from the Mastra instance
|
|
35
|
+
*/
|
|
36
|
+
private getAgent;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAIV,cAAc,EACd,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AAGpB;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,cAAc,CAAwC;gBAElD,MAAM,EAAE,gBAAgB;IAYpC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAmBjC;;OAEG;IACG,GAAG,IAAI,OAAO,CAAC,cAAc,CAAC;IAkDpC;;OAEG;YACW,QAAQ;IAsFtB;;OAEG;YACW,OAAO;IA8DrB;;OAEG;YACW,YAAY;IAsD1B;;OAEG;YACW,oBAAoB;IAwFlC;;OAEG;YACW,QAAQ;CA+CvB"}
|
package/dist/runner.js
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { pathToFileURL } from 'url';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { discoverTestFiles, loadTestSuites } from './discovery.js';
|
|
4
|
+
/**
|
|
5
|
+
* Main test runner for Mastra agents
|
|
6
|
+
*/
|
|
7
|
+
export class TestRunner {
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.mastraInstance = null;
|
|
10
|
+
this.config = {
|
|
11
|
+
projectRoot: config.projectRoot,
|
|
12
|
+
testPattern: config.testPattern ?? '**/*.mastra-test.ts',
|
|
13
|
+
agent: config.agent ?? '',
|
|
14
|
+
tags: config.tags ?? [],
|
|
15
|
+
timeout: config.timeout ?? 30000,
|
|
16
|
+
parallel: config.parallel ?? false,
|
|
17
|
+
verbose: config.verbose ?? false,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Initialize the runner and load Mastra
|
|
22
|
+
*/
|
|
23
|
+
async initialize() {
|
|
24
|
+
const possiblePaths = [
|
|
25
|
+
path.join(this.config.projectRoot, 'src', 'mastra', 'index.ts'),
|
|
26
|
+
path.join(this.config.projectRoot, 'src', 'mastra', 'index.js'),
|
|
27
|
+
path.join(this.config.projectRoot, 'mastra', 'index.ts'),
|
|
28
|
+
path.join(this.config.projectRoot, 'mastra', 'index.js'),
|
|
29
|
+
];
|
|
30
|
+
for (const mastraPath of possiblePaths) {
|
|
31
|
+
try {
|
|
32
|
+
const fileUrl = pathToFileURL(mastraPath).href;
|
|
33
|
+
this.mastraInstance = await import(fileUrl);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
// Try next path
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Run all discovered tests
|
|
43
|
+
*/
|
|
44
|
+
async run() {
|
|
45
|
+
const startTime = Date.now();
|
|
46
|
+
const results = [];
|
|
47
|
+
// Discover and load test files
|
|
48
|
+
const testFiles = await discoverTestFiles(this.config.projectRoot, this.config.testPattern);
|
|
49
|
+
if (testFiles.length === 0) {
|
|
50
|
+
return {
|
|
51
|
+
total: 0,
|
|
52
|
+
passed: 0,
|
|
53
|
+
failed: 0,
|
|
54
|
+
skipped: 0,
|
|
55
|
+
timeout: 0,
|
|
56
|
+
duration: Date.now() - startTime,
|
|
57
|
+
results: [],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const suites = await loadTestSuites(testFiles);
|
|
61
|
+
// Filter suites by agent if specified
|
|
62
|
+
const filteredSuites = this.config.agent
|
|
63
|
+
? suites.filter((s) => s.agent.toLowerCase() === this.config.agent.toLowerCase())
|
|
64
|
+
: suites;
|
|
65
|
+
// Run each suite
|
|
66
|
+
for (const suite of filteredSuites) {
|
|
67
|
+
const suiteResults = await this.runSuite(suite);
|
|
68
|
+
results.push(...suiteResults);
|
|
69
|
+
}
|
|
70
|
+
const summary = {
|
|
71
|
+
total: results.length,
|
|
72
|
+
passed: results.filter((r) => r.status === 'passed').length,
|
|
73
|
+
failed: results.filter((r) => r.status === 'failed').length,
|
|
74
|
+
skipped: results.filter((r) => r.status === 'skipped').length,
|
|
75
|
+
timeout: results.filter((r) => r.status === 'timeout').length,
|
|
76
|
+
duration: Date.now() - startTime,
|
|
77
|
+
results,
|
|
78
|
+
};
|
|
79
|
+
return summary;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Run a single test suite
|
|
83
|
+
*/
|
|
84
|
+
async runSuite(suite) {
|
|
85
|
+
const results = [];
|
|
86
|
+
// Get the agent
|
|
87
|
+
const agent = await this.getAgent(suite.agent);
|
|
88
|
+
if (!agent) {
|
|
89
|
+
// Mark all tests as skipped if agent not found
|
|
90
|
+
for (const test of suite.tests) {
|
|
91
|
+
results.push({
|
|
92
|
+
name: test.name,
|
|
93
|
+
agent: suite.agent,
|
|
94
|
+
status: 'skipped',
|
|
95
|
+
duration: 0,
|
|
96
|
+
error: `Agent "${suite.agent}" not found`,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return results;
|
|
100
|
+
}
|
|
101
|
+
// Run beforeAll
|
|
102
|
+
if (suite.beforeAll) {
|
|
103
|
+
try {
|
|
104
|
+
await suite.beforeAll();
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
// If beforeAll fails, skip all tests
|
|
108
|
+
for (const test of suite.tests) {
|
|
109
|
+
results.push({
|
|
110
|
+
name: test.name,
|
|
111
|
+
agent: suite.agent,
|
|
112
|
+
status: 'skipped',
|
|
113
|
+
duration: 0,
|
|
114
|
+
error: `beforeAll failed: ${error}`,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return results;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// Filter tests by tags if specified
|
|
121
|
+
const tests = this.config.tags.length > 0
|
|
122
|
+
? suite.tests.filter((t) => t.tags?.some((tag) => this.config.tags.includes(tag)))
|
|
123
|
+
: suite.tests;
|
|
124
|
+
// Run each test
|
|
125
|
+
for (const test of tests) {
|
|
126
|
+
if (suite.beforeEach) {
|
|
127
|
+
try {
|
|
128
|
+
await suite.beforeEach();
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
results.push({
|
|
132
|
+
name: test.name,
|
|
133
|
+
agent: suite.agent,
|
|
134
|
+
status: 'failed',
|
|
135
|
+
duration: 0,
|
|
136
|
+
error: `beforeEach failed: ${error}`,
|
|
137
|
+
});
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const result = await this.runTest(suite.agent, agent, test);
|
|
142
|
+
results.push(result);
|
|
143
|
+
if (suite.afterEach) {
|
|
144
|
+
try {
|
|
145
|
+
await suite.afterEach();
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
// Log but don't fail
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// Run afterAll
|
|
153
|
+
if (suite.afterAll) {
|
|
154
|
+
try {
|
|
155
|
+
await suite.afterAll();
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
// Log but don't fail
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return results;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Run a single test case
|
|
165
|
+
*/
|
|
166
|
+
async runTest(agentName, agent, test) {
|
|
167
|
+
const startTime = Date.now();
|
|
168
|
+
const timeout = test.timeout ?? this.config.timeout;
|
|
169
|
+
try {
|
|
170
|
+
// Create a promise that rejects on timeout
|
|
171
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
172
|
+
setTimeout(() => reject(new Error('Test timeout')), timeout);
|
|
173
|
+
});
|
|
174
|
+
// Execute the agent
|
|
175
|
+
const executePromise = this.executeAgent(agent, test.input);
|
|
176
|
+
const { output, toolCalls } = await Promise.race([
|
|
177
|
+
executePromise,
|
|
178
|
+
timeoutPromise,
|
|
179
|
+
]);
|
|
180
|
+
// Validate expectations
|
|
181
|
+
const validationResult = await this.validateExpectations(output, toolCalls, test.expect);
|
|
182
|
+
if (validationResult.passed) {
|
|
183
|
+
return {
|
|
184
|
+
name: test.name,
|
|
185
|
+
agent: agentName,
|
|
186
|
+
status: 'passed',
|
|
187
|
+
duration: Date.now() - startTime,
|
|
188
|
+
output,
|
|
189
|
+
toolCalls,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
return {
|
|
194
|
+
name: test.name,
|
|
195
|
+
agent: agentName,
|
|
196
|
+
status: 'failed',
|
|
197
|
+
duration: Date.now() - startTime,
|
|
198
|
+
error: validationResult.error,
|
|
199
|
+
output,
|
|
200
|
+
toolCalls,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
catch (error) {
|
|
205
|
+
const isTimeout = error instanceof Error && error.message === 'Test timeout';
|
|
206
|
+
return {
|
|
207
|
+
name: test.name,
|
|
208
|
+
agent: agentName,
|
|
209
|
+
status: isTimeout ? 'timeout' : 'failed',
|
|
210
|
+
duration: Date.now() - startTime,
|
|
211
|
+
error: error instanceof Error ? error.message : String(error),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Execute an agent with the given input
|
|
217
|
+
*/
|
|
218
|
+
async executeAgent(agent, input) {
|
|
219
|
+
const messages = Array.isArray(input) ? input : [input];
|
|
220
|
+
const toolCalls = [];
|
|
221
|
+
// Check if agent has generate method
|
|
222
|
+
if (typeof agent.generate !== 'function') {
|
|
223
|
+
throw new Error('Agent does not have a generate method');
|
|
224
|
+
}
|
|
225
|
+
// Format messages for Mastra
|
|
226
|
+
const formattedMessages = messages.map((content) => ({
|
|
227
|
+
role: 'user',
|
|
228
|
+
content,
|
|
229
|
+
}));
|
|
230
|
+
// Call generate with onStepFinish to capture tool calls
|
|
231
|
+
const result = await agent.generate({
|
|
232
|
+
messages: formattedMessages,
|
|
233
|
+
onStepFinish: (step) => {
|
|
234
|
+
if (step.toolCalls && Array.isArray(step.toolCalls)) {
|
|
235
|
+
for (const call of step.toolCalls) {
|
|
236
|
+
toolCalls.push({
|
|
237
|
+
name: call.toolName,
|
|
238
|
+
args: call.args,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
// Extract text from result
|
|
245
|
+
let output = '';
|
|
246
|
+
if (typeof result === 'string') {
|
|
247
|
+
output = result;
|
|
248
|
+
}
|
|
249
|
+
else if (result && typeof result === 'object') {
|
|
250
|
+
output =
|
|
251
|
+
result.text ??
|
|
252
|
+
result.content ??
|
|
253
|
+
JSON.stringify(result);
|
|
254
|
+
}
|
|
255
|
+
return { output, toolCalls };
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Validate test expectations against output
|
|
259
|
+
*/
|
|
260
|
+
async validateExpectations(output, toolCalls, expect) {
|
|
261
|
+
const outputLower = output.toLowerCase();
|
|
262
|
+
// Check contains
|
|
263
|
+
if (expect.contains) {
|
|
264
|
+
const containsList = Array.isArray(expect.contains)
|
|
265
|
+
? expect.contains
|
|
266
|
+
: [expect.contains];
|
|
267
|
+
for (const text of containsList) {
|
|
268
|
+
if (!outputLower.includes(text.toLowerCase())) {
|
|
269
|
+
return {
|
|
270
|
+
passed: false,
|
|
271
|
+
error: `Expected output to contain "${text}"`,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
// Check notContains
|
|
277
|
+
if (expect.notContains) {
|
|
278
|
+
const notContainsList = Array.isArray(expect.notContains)
|
|
279
|
+
? expect.notContains
|
|
280
|
+
: [expect.notContains];
|
|
281
|
+
for (const text of notContainsList) {
|
|
282
|
+
if (outputLower.includes(text.toLowerCase())) {
|
|
283
|
+
return {
|
|
284
|
+
passed: false,
|
|
285
|
+
error: `Expected output to NOT contain "${text}"`,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
// Check regex match
|
|
291
|
+
if (expect.matches) {
|
|
292
|
+
const regex = expect.matches instanceof RegExp
|
|
293
|
+
? expect.matches
|
|
294
|
+
: new RegExp(expect.matches);
|
|
295
|
+
if (!regex.test(output)) {
|
|
296
|
+
return {
|
|
297
|
+
passed: false,
|
|
298
|
+
error: `Expected output to match pattern ${regex}`,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
// Check custom validator
|
|
303
|
+
if (expect.validate) {
|
|
304
|
+
const isValid = await expect.validate(output);
|
|
305
|
+
if (!isValid) {
|
|
306
|
+
return {
|
|
307
|
+
passed: false,
|
|
308
|
+
error: 'Custom validation failed',
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
// Check tool calls
|
|
313
|
+
if (expect.toolCalls) {
|
|
314
|
+
for (const expectedCall of expect.toolCalls) {
|
|
315
|
+
const found = toolCalls.find((tc) => tc.name === expectedCall.name);
|
|
316
|
+
if (!found) {
|
|
317
|
+
return {
|
|
318
|
+
passed: false,
|
|
319
|
+
error: `Expected tool "${expectedCall.name}" to be called`,
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
if (expectedCall.args) {
|
|
323
|
+
for (const [key, value] of Object.entries(expectedCall.args)) {
|
|
324
|
+
if (found.args[key] !== value) {
|
|
325
|
+
return {
|
|
326
|
+
passed: false,
|
|
327
|
+
error: `Expected tool "${expectedCall.name}" to be called with ${key}=${value}`,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return { passed: true };
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Get an agent by name from the Mastra instance
|
|
338
|
+
*/
|
|
339
|
+
async getAgent(name) {
|
|
340
|
+
if (!this.mastraInstance) {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
// Try direct export
|
|
344
|
+
if (this.mastraInstance[name]) {
|
|
345
|
+
return this.mastraInstance[name];
|
|
346
|
+
}
|
|
347
|
+
// Try mastra.getAgent()
|
|
348
|
+
const mastra = this.mastraInstance.mastra;
|
|
349
|
+
if (mastra && typeof mastra.getAgent === 'function') {
|
|
350
|
+
try {
|
|
351
|
+
return (await mastra.getAgent(name));
|
|
352
|
+
}
|
|
353
|
+
catch {
|
|
354
|
+
// Agent not found
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
// Try agents property
|
|
358
|
+
if (mastra && mastra.agents) {
|
|
359
|
+
const agents = mastra.agents;
|
|
360
|
+
if (agents[name]) {
|
|
361
|
+
return agents[name];
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
// Search through all exports for matching agent
|
|
365
|
+
for (const value of Object.values(this.mastraInstance)) {
|
|
366
|
+
if (value &&
|
|
367
|
+
typeof value === 'object' &&
|
|
368
|
+
(value.name === name ||
|
|
369
|
+
value.id === name)) {
|
|
370
|
+
return value;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,IAAI,MAAM,MAAM,CAAC;AASxB,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEnE;;GAEG;AACH,MAAM,OAAO,UAAU;IAIrB,YAAY,MAAwB;QAF5B,mBAAc,GAAmC,IAAI,CAAC;QAG5D,IAAI,CAAC,MAAM,GAAG;YACZ,WAAW,EAAE,MAAM,CA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-0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for a single test case
|
|
3
|
+
*/
|
|
4
|
+
export interface TestCase {
|
|
5
|
+
/** Unique name for this test */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Input message(s) to send to the agent */
|
|
8
|
+
input: string | string[];
|
|
9
|
+
/** Expected behavior assertions */
|
|
10
|
+
expect: TestExpectation;
|
|
11
|
+
/** Optional timeout in milliseconds (default: 30000) */
|
|
12
|
+
timeout?: number;
|
|
13
|
+
/** Optional tags for filtering tests */
|
|
14
|
+
tags?: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Expectations for test output
|
|
18
|
+
*/
|
|
19
|
+
export interface TestExpectation {
|
|
20
|
+
/** Output should contain this text (case-insensitive) */
|
|
21
|
+
contains?: string | string[];
|
|
22
|
+
/** Output should not contain this text */
|
|
23
|
+
notContains?: string | string[];
|
|
24
|
+
/** Output should match this regex pattern */
|
|
25
|
+
matches?: string | RegExp;
|
|
26
|
+
/** Custom validation function */
|
|
27
|
+
validate?: (output: string) => boolean | Promise<boolean>;
|
|
28
|
+
/** Expected tool calls */
|
|
29
|
+
toolCalls?: ExpectedToolCall[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Expected tool call during agent execution
|
|
33
|
+
*/
|
|
34
|
+
export interface ExpectedToolCall {
|
|
35
|
+
/** Name of the tool that should be called */
|
|
36
|
+
name: string;
|
|
37
|
+
/** Optional: expected arguments (partial match) */
|
|
38
|
+
args?: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Test suite for an agent
|
|
42
|
+
*/
|
|
43
|
+
export interface AgentTestSuite {
|
|
44
|
+
/** Agent name or ID to test */
|
|
45
|
+
agent: string;
|
|
46
|
+
/** Optional description */
|
|
47
|
+
description?: string;
|
|
48
|
+
/** Test cases */
|
|
49
|
+
tests: TestCase[];
|
|
50
|
+
/** Setup function run before all tests */
|
|
51
|
+
beforeAll?: () => void | Promise<void>;
|
|
52
|
+
/** Teardown function run after all tests */
|
|
53
|
+
afterAll?: () => void | Promise<void>;
|
|
54
|
+
/** Setup function run before each test */
|
|
55
|
+
beforeEach?: () => void | Promise<void>;
|
|
56
|
+
/** Teardown function run after each test */
|
|
57
|
+
afterEach?: () => void | Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Result of a single test execution
|
|
61
|
+
*/
|
|
62
|
+
export interface TestResult {
|
|
63
|
+
/** Test case name */
|
|
64
|
+
name: string;
|
|
65
|
+
/** Agent being tested */
|
|
66
|
+
agent: string;
|
|
67
|
+
/** Pass/fail status */
|
|
68
|
+
status: 'passed' | 'failed' | 'skipped' | 'timeout';
|
|
69
|
+
/** Execution time in milliseconds */
|
|
70
|
+
duration: number;
|
|
71
|
+
/** Error message if failed */
|
|
72
|
+
error?: string;
|
|
73
|
+
/** Agent output */
|
|
74
|
+
output?: string;
|
|
75
|
+
/** Tool calls made during execution */
|
|
76
|
+
toolCalls?: Array<{
|
|
77
|
+
name: string;
|
|
78
|
+
args: Record<string, unknown>;
|
|
79
|
+
}>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Summary of test run
|
|
83
|
+
*/
|
|
84
|
+
export interface TestRunSummary {
|
|
85
|
+
/** Total tests run */
|
|
86
|
+
total: number;
|
|
87
|
+
/** Tests passed */
|
|
88
|
+
passed: number;
|
|
89
|
+
/** Tests failed */
|
|
90
|
+
failed: number;
|
|
91
|
+
/** Tests skipped */
|
|
92
|
+
skipped: number;
|
|
93
|
+
/** Tests that timed out */
|
|
94
|
+
timeout: number;
|
|
95
|
+
/** Total duration in milliseconds */
|
|
96
|
+
duration: number;
|
|
97
|
+
/** Individual test results */
|
|
98
|
+
results: TestResult[];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Configuration for the test runner
|
|
102
|
+
*/
|
|
103
|
+
export interface TestRunnerConfig {
|
|
104
|
+
/** Path to Mastra project root */
|
|
105
|
+
projectRoot: string;
|
|
106
|
+
/** Glob pattern for test files (default: **\/*.mastra-test.ts) */
|
|
107
|
+
testPattern?: string;
|
|
108
|
+
/** Filter tests by agent name */
|
|
109
|
+
agent?: string;
|
|
110
|
+
/** Filter tests by tag */
|
|
111
|
+
tags?: string[];
|
|
112
|
+
/** Default timeout for tests in ms */
|
|
113
|
+
timeout?: number;
|
|
114
|
+
/** Run tests in parallel */
|
|
115
|
+
parallel?: boolean;
|
|
116
|
+
/** Verbose output */
|
|
117
|
+
verbose?: boolean;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Discovered agent information
|
|
121
|
+
*/
|
|
122
|
+
export interface DiscoveredAgent {
|
|
123
|
+
/** Agent name/id */
|
|
124
|
+
name: string;
|
|
125
|
+
/** Agent instructions (if available) */
|
|
126
|
+
instructions?: string;
|
|
127
|
+
/** Tools available to the agent */
|
|
128
|
+
tools?: string[];
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,mCAAmC;IACnC,MAAM,EAAE,eAAe,CAAC;IACxB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,yDAAyD;IACzD,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC7B,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,6CAA6C;IAC7C,OAAO,CAA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js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DiscoveredAgent } from '../types.js';
|
|
2
|
+
interface AgentListUIProps {
|
|
3
|
+
agents: DiscoveredAgent[];
|
|
4
|
+
}
|
|
5
|
+
export declare function AgentListUI({ agents }: AgentListUIProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=AgentList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentList.d.ts","sourceRoot":"","sources":["../../src/ui/AgentList.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,UAAU,gBAAgB;IACxB,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B;AAED,wBAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,gBAAgB,2CAyBvD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Text, Newline } from 'ink';
|
|
3
|
+
export function AgentListUI({ agents }) {
|
|
4
|
+
return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsx(Box, { marginBottom: 1, children: _jsx(Text, { bold: true, color: "magenta", children: "\u25C6 Discovered Agents" }) }), agents.length === 0 ? (_jsx(Box, { children: _jsx(Text, { color: "yellow", children: "\u26A0 No agents found in the project" }) })) : (_jsx(Box, { flexDirection: "column", children: agents.map((agent, index) => (_jsx(AgentCard, { agent: agent }, index))) })), _jsx(Newline, {}), _jsxs(Text, { color: "gray", children: ["Found ", agents.length, " agent(s)"] })] }));
|
|
5
|
+
}
|
|
6
|
+
function AgentCard({ agent }) {
|
|
7
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, borderStyle: "round", borderColor: "cyan", paddingX: 2, paddingY: 1, children: [_jsx(Box, { children: _jsxs(Text, { color: "cyan", bold: true, children: ["\u25CF ", agent.name] }) }), agent.instructions && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { color: "gray", wrap: "wrap", children: agent.instructions.length > 150
|
|
8
|
+
? agent.instructions.slice(0, 150) + '...'
|
|
9
|
+
: agent.instructions }) })), agent.tools && agent.tools.length > 0 && (_jsxs(Box, { marginTop: 1, children: [_jsx(Text, { color: "blue", children: "Tools: " }), _jsx(Text, { children: agent.tools.join(', ') })] }))] }));
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=AgentList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentList.js","sourceRoot":"","sources":["../../src/ui/AgentList.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAOzC,MAAM,UAAU,WAAW,CAAC,EAAE,MAAM,EAAoB;IACtD,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,OAAO,EAAE,CAAC,aACpC,KAAC,GAAG,IAAC,YAAY,EAAE,CAAC,YAClB,KAAC,IAAI,IAAC,IAAI,QAAC,KAAK,EAAC,SAAS,yCAEnB,GACH,EAEL,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CACrB,KAAC,GAAG,cACF,KAAC,IAAI,IAAC,KAAK,EAAC,QAAQ,sDAAwC,GACxD,CACP,CAAC,CAAC,CAAC,CACF,KAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,YACxB,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAC5B,KAAC,SAAS,IAAa,KAAK,EAAE,KAAK,IAAnB,KAAK,CAAkB,CACxC,CAAC,GACE,CACP,EAED,KAAC,OAAO,KAAG,EACX,MAAC,IAAI,IAAC,KAAK,EAAC,MAAM,uBAAQ,MAAM,CAAC,MAAM,iBAAiB,IACpD,CACP,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,EAAE,KAAK,EAA8B;IACtD,OAAO,CACL,MAAC,GAAG,IAAC,aAAa,EAAC,QAAQ,EAAC,YAAY,EAAE,CAAC,EAAE,WAAW,EAAC,OAAO,EAAC,WAAW,EAAC,MAAM,EAAC,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,aAC1G,KAAC,GAAG,cACF,MAAC,IAAI,IAAC,KAAK,EAAC,MAAM,EAAC,IAAI,8BAClB,KAAK,CAAC,IAAI,IACR,GACH,EAEL,KAAK,CAAC,YAAY,IAAI,CACrB,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,YACf,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,EAAC,IAAI,EAAC,MAAM,YAC3B,KAAK,CAAC,YAAY,CAAC,MAAM,GAAG,GAAG;wBAC9B,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK;wBAC1C,CAAC,CAAC,KAAK,CAAC,YAAY,GACjB,GACH,CACP,EAEA,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CACxC,MAAC,GAAG,IAAC,SAAS,EAAE,CAAC,aACf,KAAC,IAAI,IAAC,KAAK,EAAC,MAAM,wBAAe,EACjC,KAAC,IAAI,cAAE,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAQ,IACjC,CACP,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TestRunSummary, AgentTestSuite } from '../types.js';
|
|
2
|
+
interface TestRunnerUIProps {
|
|
3
|
+
projectRoot: string;
|
|
4
|
+
testPattern: string;
|
|
5
|
+
agent?: string;
|
|
6
|
+
tags?: string[];
|
|
7
|
+
timeout: number;
|
|
8
|
+
parallel: boolean;
|
|
9
|
+
verbose: boolean;
|
|
10
|
+
suites: AgentTestSuite[];
|
|
11
|
+
onComplete: (summary: TestRunSummary) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function TestRunnerUI({ projectRoot, testPattern, agent, tags, timeout, parallel, verbose, suites, onComplete, }: TestRunnerUIProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=TestRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestRunner.d.ts","sourceRoot":"","sources":["../../src/ui/TestRunner.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAc,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG9E,UAAU,iBAAiB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,UAAU,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,CAAC;CAC/C;AAED,wBAAgB,YAAY,CAAC,EAC3B,WAAW,EACX,WAAW,EACX,KAAK,EACL,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,OAAO,EACP,MAAM,EACN,UAAU,GACX,EAAE,iBAAiB,2CAkDnB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { Box, Text, Newline } from 'ink';
|
|
4
|
+
import Spinner from 'ink-spinner';
|
|
5
|
+
import { TestRunner } from '../runner.js';
|
|
6
|
+
export function TestRunnerUI({ projectRoot, testPattern, agent, tags, timeout, parallel, verbose, suites, onComplete, }) {
|
|
7
|
+
const [status, setStatus] = useState('running');
|
|
8
|
+
const [currentTest] = useState('Initializing...');
|
|
9
|
+
const [results, setResults] = useState([]);
|
|
10
|
+
const [summary, setSummary] = useState(null);
|
|
11
|
+
const testCount = suites.reduce((acc, s) => acc + s.tests.length, 0);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
async function run() {
|
|
14
|
+
const runner = new TestRunner({
|
|
15
|
+
projectRoot,
|
|
16
|
+
testPattern,
|
|
17
|
+
agent,
|
|
18
|
+
tags,
|
|
19
|
+
timeout,
|
|
20
|
+
parallel,
|
|
21
|
+
verbose,
|
|
22
|
+
});
|
|
23
|
+
await runner.initialize();
|
|
24
|
+
const result = await runner.run();
|
|
25
|
+
setResults(result.results);
|
|
26
|
+
setSummary(result);
|
|
27
|
+
setStatus('complete');
|
|
28
|
+
onComplete(result);
|
|
29
|
+
}
|
|
30
|
+
run();
|
|
31
|
+
}, []);
|
|
32
|
+
return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsx(Header, { testCount: testCount, suiteCount: suites.length }), status === 'running' && (_jsxs(Box, { marginY: 1, children: [_jsx(Text, { color: "cyan", children: _jsx(Spinner, { type: "dots" }) }), _jsxs(Text, { children: [" ", currentTest] })] })), _jsx(ResultsList, { results: results, verbose: verbose }), summary && _jsx(Summary, { summary: summary })] }));
|
|
33
|
+
}
|
|
34
|
+
function Header({ testCount, suiteCount }) {
|
|
35
|
+
return (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Box, { children: _jsx(Text, { bold: true, color: "magenta", children: "\u25C6 Mastra Agent Tests" }) }), _jsxs(Text, { color: "gray", children: ["Running ", testCount, " tests from ", suiteCount, " suites"] })] }));
|
|
36
|
+
}
|
|
37
|
+
function ResultsList({ results, verbose }) {
|
|
38
|
+
if (results.length === 0)
|
|
39
|
+
return null;
|
|
40
|
+
return (_jsx(Box, { flexDirection: "column", marginY: 1, children: results.map((result, index) => (_jsx(TestResultRow, { result: result, verbose: verbose }, index))) }));
|
|
41
|
+
}
|
|
42
|
+
function TestResultRow({ result, verbose }) {
|
|
43
|
+
const icon = getStatusIcon(result.status);
|
|
44
|
+
const color = getStatusColor(result.status);
|
|
45
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: color, children: icon }), _jsxs(Text, { color: "cyan", children: [" [", result.agent, "]"] }), _jsxs(Text, { children: [" ", result.name] }), _jsxs(Text, { color: "gray", children: [" (", result.duration, "ms)"] })] }), result.status === 'failed' && result.error && (_jsx(Box, { marginLeft: 4, children: _jsxs(Text, { color: "red", children: ["\u2192 ", result.error] }) })), verbose && result.output && (_jsx(Box, { marginLeft: 4, children: _jsxs(Text, { color: "gray", children: ["Output: ", result.output.slice(0, 100), "..."] }) }))] }));
|
|
46
|
+
}
|
|
47
|
+
function Summary({ summary }) {
|
|
48
|
+
const allPassed = summary.failed === 0 && summary.timeout === 0;
|
|
49
|
+
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, borderStyle: "single", borderColor: "gray", paddingX: 2, paddingY: 1, children: [_jsx(Text, { bold: true, children: "Test Summary" }), _jsx(Newline, {}), _jsxs(Box, { gap: 2, children: [summary.passed > 0 && (_jsxs(Text, { color: "green", children: ["\u2713 ", summary.passed, " passed"] })), summary.failed > 0 && (_jsxs(Text, { color: "red", children: ["\u2716 ", summary.failed, " failed"] })), summary.skipped > 0 && (_jsxs(Text, { color: "yellow", children: ["\u25CB ", summary.skipped, " skipped"] })), summary.timeout > 0 && (_jsxs(Text, { color: "yellow", children: ["\u23F1 ", summary.timeout, " timeout"] }))] }), _jsx(Newline, {}), _jsxs(Text, { color: "gray", children: ["Total: ", summary.total, " tests in ", summary.duration, "ms"] }), _jsx(Newline, {}), allPassed ? (summary.total === 0 ? (_jsx(Text, { color: "yellow", bold: true, children: "\u26A0 No tests found" })) : (_jsx(Text, { color: "green", bold: true, children: "\u2713 All tests passed" }))) : (_jsx(Text, { color: "red", bold: true, children: "\u2716 Tests failed" }))] }));
|
|
50
|
+
}
|
|
51
|
+
function getStatusIcon(status) {
|
|
52
|
+
switch (status) {
|
|
53
|
+
case 'passed':
|
|
54
|
+
return '✓';
|
|
55
|
+
case 'failed':
|
|
56
|
+
return '✖';
|
|
57
|
+
case 'skipped':
|
|
58
|
+
return '○';
|
|
59
|
+
case 'timeout':
|
|
60
|
+
return '⏱';
|
|
61
|
+
default:
|
|
62
|
+
return '?';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function getStatusColor(status) {
|
|
66
|
+
switch (status) {
|
|
67
|
+
case 'passed':
|
|
68
|
+
return 'green';
|
|
69
|
+
case 'failed':
|
|
70
|
+
return 'red';
|
|
71
|
+
case 'skipped':
|
|
72
|
+
return 'yellow';
|
|
73
|
+
case 'timeout':
|
|
74
|
+
return 'yellow';
|
|
75
|
+
default:
|
|
76
|
+
return 'white';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=TestRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestRunner.js","sourceRoot":"","sources":["../../src/ui/TestRunner.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,OAAO,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAc1C,MAAM,UAAU,YAAY,CAAC,EAC3B,WAAW,EACX,WAAW,EACX,KAAK,EACL,IAAI,EACJ,OAAO,EACP,QAAQ,EACR,OAAO,EACP,MAAM,EACN,UAAU,GACQ;IAClB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAyB,SAAS,CAAC,CAAC;IACxE,MAAM,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAS,iBAAiB,CAAC,CAAC;IAC1D,MAAM,CAAC,OAAO,EAAE,UA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ACZ,OAAO,QAAQ,CAAC;QAClB;YACE,OAAO,OAAO,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/ui/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voltade/mastra-unit-test",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Unit testing framework for Mastra AI agents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"mastra-test": "./dist/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./types": {
|
|
18
|
+
"types": "./dist/types.d.ts",
|
|
19
|
+
"import": "./dist/types.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"clean": "rm -rf dist",
|
|
29
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
30
|
+
"lint": "tsc --noEmit",
|
|
31
|
+
"dev": "tsc --watch"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"mastra",
|
|
35
|
+
"testing",
|
|
36
|
+
"ai",
|
|
37
|
+
"agents",
|
|
38
|
+
"unit-test"
|
|
39
|
+
],
|
|
40
|
+
"author": "Voltade",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@mastra/core": ">=0.1.0",
|
|
47
|
+
"typescript": ">=5.0.0"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"chalk": "^5.3.0",
|
|
51
|
+
"commander": "^12.0.0",
|
|
52
|
+
"glob": "^10.3.0",
|
|
53
|
+
"ink": "^5.0.1",
|
|
54
|
+
"ink-spinner": "^5.0.0",
|
|
55
|
+
"react": "^18.2.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/node": "^20.0.0",
|
|
59
|
+
"@types/react": "^18.2.0",
|
|
60
|
+
"typescript": "^5.0.0"
|
|
61
|
+
}
|
|
62
|
+
}
|