@forestadmin/代理测试
林业管理局代理检测设施。 测试本地定制( 动作、 钩子、 片段、 图表) , 而不连接 Forest Admin 服务器 .
安装
npm install --save-dev @forestadmin/agent-testing
快速启动
import {
createAgentTestClient,
createForestServerSandbox,
} from '@forestadmin/agent-testing';
describe('My Agent', () => {
let sandbox, client;
beforeAll(async () => {
// 1. Start a local sandbox that replaces Forest Admin servers
sandbox = await createForestServerSandbox(3001);
// 2. Start your agent pointing to the sandbox
// FOREST_SERVER_URL=http://localhost:3001 node your-agent.js
// 3. Connect the test client
client = await createAgentTestClient({
serverUrl: 'http://localhost:3001',
agentUrl: 'http://localhost:3310',
agentSchemaPath: './.forestadmin-schema.json',
agentForestEnvSecret: process.env.FOREST_ENV_SECRET,
agentForestAuthSecret: process.env.FOREST_AUTH_SECRET,
});
});
afterAll(async () => {
await sandbox?.close();
});
it('should list users', async () => {
const users = await client.collection('users').list();
expect(users.length).toBeGreaterThan(0);
});
});
许可证
阿帕奇 - 2.0