Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问clear审计提醒

n8n-trigger-testing-strategiesn8n 触发测试策略

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

1,854

周安装

75

GitHub Stars

331

下载量

582
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:n8n-trigger-testing-strategies(n8n 触发测试策略)
来源仓库:https://github.com/proffesor-for-testing/agentic-qe
仓库路径:skills/n8n-trigger-testing-strategies
安装命令:
npx skills add https://github.com/proffesor-for-testing/agentic-qe --skill n8n-trigger-testing-strategies
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/proffesor-for-testing/agentic-qe --skill n8n-trigger-testing-strategies

简介

用于辅助测试设计、自动化测试和回归验证。

  • 适合让 Agent 编写单元测试、端到端测试或根据失败日志定位问题。
  • 使用时需确认项目测试框架和运行命令。n8n-trigger-testing-strategies 属于研究检索类 Skill,可作为该场景下的辅助能力补充。
  • 安装方式:通过 npx skills add 命令从指定 GitHub 仓库安装。
  • 注意:涉及浏览器或外部服务时应区分本地模拟与生产环境。

SKILL.md

n8n Trigger Testing Strategies

<default_to_action> When testing n8n triggers:

  1. IDENTIFY trigger type (webhook, schedule, polling, event)
  2. TEST with various valid payloads
  3. VERIFY authentication and authorization
  4. CHECK error handling for invalid inputs
  5. MEASURE response time and reliability

Quick Trigger Checklist:

  • Trigger activates workflow correctly
  • Payload parsed and validated
  • Authentication enforced (if configured)
  • Error responses are informative
  • Response time is acceptable

Critical Success Factors:

  • Test edge cases (empty payloads, large payloads)
  • Verify idempotency where needed
  • Check timeout handling
  • Monitor for missed triggers </default_to_action>

Quick Reference Card

n8n Trigger Types

TypeUse CaseTesting Focus
WebhookExternal HTTP callsPayloads, auth, methods
ScheduleTimed executionCron accuracy, timezone
PollingCheck for changesInterval, deduplication
EventService eventsEvent handling, filtering

Common Webhook Configurations

SettingOptionsImpact
HTTP MethodGET, POST, PUT, DELETERequest handling
AuthenticationNone, Basic, HeaderSecurity
Response ModeImmediately, Last Node, CustomResponse timing
PathCustom URL pathEndpoint identification

Webhook Testing

Basic Webhook Test

// Test webhook with various payloads
async function testWebhook(webhookUrl: string): Promise<WebhookTestResult> {
  const testPayloads = [
    // Valid JSON
    { type: 'json', data: { event: 'test', timestamp: Date.now() } },
    // Empty object
    { type: 'empty', data: {} },
    // Large payload
    { type: 'large', data: { items: Array(1000).fill({ id: 1, name: 'test' }) } },
    // Nested data
    { type: 'nested', data: { level1: { level2: { level3: { value: 'deep' } } } } },
    // Special characters
    { type: 'special', data: { text: 'Hello <script>alert("xss")</script>' } }
  ];

  const results: PayloadTestResult[] = [];

  for (const payload of testPayloads) {
    const startTime = Date.now();

    try {
      const response = await fetch(webhookUrl, {
        method: 'POST',
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify(payload.data)
      });

      results.push({
        payloadType: payload.type,
        success: response.ok,
        status: response.status,
        responseTime: Date.now() - startTime,
        responseBody: await response.text()
      });
    } catch (error) {
      results.push({
        payloadType: payload.type,
        success: false,
        error: error.message
      });
    }
  }

  return { webhookUrl, results };
}

HTTP Method Testing

// Test all HTTP methods
async function testWebhookMethods(webhookUrl: string): Promise<MethodTestResult[]> {
  const methods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'];
  const results: MethodTestResult[] = [];

  for (const method of methods) {
    try {
      const response = await fetch(webhookUrl, {
        method,
        headers: { 'Content-Type': 'application/json' },
        body: ['GET', 'HEAD', 'OPTIONS'].includes(method) ? undefined : '{}'
      });

      results.push({
        method,
        allowed: response.ok || response.status !== 405,
        status: response.status,
        statusText: response.statusText
      });
    } catch (error) {
      results.push({
        method,
        allowed: false,
        error: error.message
      });
    }
  }

  return results;
}

Authentication Testing

// Test webhook authentication
async function testWebhookAuth(webhookUrl: string, authConfig: AuthConfig): Promise<AuthTestResult> {
  const scenarios = [
    // No auth
    { name: 'no-auth', headers: {} },
    // Invalid auth
    { name: 'invalid-auth', headers: { 'Authorization': 'Bearer invalid-token' } },
    // Valid auth
    { name: 'valid-auth', headers: { 'Authorization': `Bearer ${authConfig.token}` } },
    // Expired auth
    { name: 'expired-auth', headers: { 'Authorization': `Bearer ${authConfig.expiredToken}` } }
  ];

  const results: AuthScenarioResult[] = [];

  for (const scenario of scenarios) {
    const response = await fetch(webhookUrl, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        ...scenario.headers
      },
      body: '{}'
    });

    results.push({
      scenario: scenario.name,
      status: response.status,
      authenticated: response.ok,
      errorMessage: response.ok ? null : await response.text()
    });
  }

  return {
    authRequired: !results.find(r => r.scenario === 'no-auth')?.authenticated,
    invalidRejected: !results.find(r => r.scenario === 'invalid-auth')?.authenticated,
    validAccepted: results.find(r => r.scenario === 'valid-auth')?.authenticated,
    results
  };
}

Schedule Testing

Cron Expression Validation

// Validate cron expression
function validateCronExpression(expression: string): CronValidationResult {
  const parts = expression.trim().split(/\s+/);

  if (parts.length < 5 || parts.length > 6) {
    return {
      valid: false,
      error: `Expected 5-6 parts, got ${parts.length}`
    };
  }

  const [minute, hour, dayOfMonth, month, dayOfWeek, year] = parts;

  const validations = [
    { field: 'minute', value: minute, range: [0, 59] },
    { field: 'hour', value: hour, range: [0, 23] },
    { field: 'dayOfMonth', value: dayOfMonth, range: [1, 31] },
    { field: 'month', value: month, range: [1, 12] },
    { field: 'dayOfWeek', value: dayOfWeek, range: [0, 7] }
  ];

  for (const v of validations) {
    const result = validateCronField(v.value, v.range);
    if (!result.valid) {
      return { valid: false, error: `Invalid ${v.field}: ${result.error}` };
    }
  }

  return {
    valid: true,
    description: describeCronExpression(expression),
    nextExecutions: getNextCronExecutions(expression, 5)
  };
}

// Get human-readable description
function describeCronExpression(expression: string): string {
  // Common patterns
  const patterns: Record<string, string> = {
    '* * * * *': 'Every minute',
    '*/5 * * * *': 'Every 5 minutes',
    '0 * * * *': 'Every hour',
    '0 0 * * *': 'Every day at midnight',
    '0 9 * * 1-5': 'Weekdays at 9:00 AM',
    '0 0 1 * *': 'First day of every month',
    '0 0 * * 0': 'Every Sunday at midnight'
  };

  return patterns[expression] || 'Custom schedule';
}

// Calculate next execution times
function getNextCronExecutions(expression: string, count: number): Date[] {
  const executions: Date[] = [];
  let current = new Date();

  // Simple implementation - use cron-parser library in production
  for (let i = 0; i < count; i++) {
    const next = calculateNextCronExecution(expression, current);
    executions.push(next);
    current = new Date(next.getTime() + 60000); // Move past this execution
  }

  return executions;
}

Schedule Reliability Testing

// Test schedule trigger reliability
async function testScheduleReliability(triggerId: string, testDuration: number): Promise<ScheduleTestResult> {
  const startTime = Date.now();
  const expectedExecutions: Date[] = [];
  const actualExecutions: Date[] = [];

  // Calculate expected execution times
  const cronExpression = await getTriggerCronExpression(triggerId);
  let checkTime = new Date(startTime);
  while (checkTime.getTime() < startTime + testDuration) {
    const nextExec = calculateNextCronExecution(cronExpression, checkTime);
    if (nextExec.getTime() < startTime + testDuration) {
      expectedExecutions.push(nextExec);
    }
    checkTime = new Date(nextExec.getTime() + 60000);
  }

  // Monitor actual executions
  const executionListener = onExecutionStart(triggerId, (exec) => {
    actualExecutions.push(new Date(exec.startedAt));
  });

  // Wait for test duration
  await sleep(testDuration);
  executionListener.stop();

  // Compare expected vs actual
  const comparison = compareExecutions(expectedExecutions, actualExecutions);

  return {
    testDuration,
    expectedCount: expectedExecutions.length,
    actualCount: actualExecutions.length,
    missedExecutions: comparison.missed,
    extraExecutions: comparison.extra,
    timingAccuracy: comparison.timingAccuracy,
    reliability: (actualExecutions.length / expectedExecutions.length) * 100
  };
}

Polling Trigger Testing

// Test polling trigger behavior
async function testPollingTrigger(triggerId: string, testConfig: PollingTestConfig): Promise<PollingTestResult> {
  const { interval, testDuration, simulateDataChanges } = testConfig;

  const pollEvents: PollEvent[] = [];
  const triggeredExecutions: Execution[] = [];

  // Monitor polling events
  const pollListener = onPoll(triggerId, (event) => {
    pollEvents.push({
      timestamp: new Date(),
      dataFound: event.hasNewData,
      itemCount: event.items?.length || 0
    });
  });

  // Monitor triggered executions
  const execListener = onExecutionStart(triggerId, (exec) => {
    triggeredExecutions.push(exec);
  });

  // Optionally simulate data changes
  if (simulateDataChanges) {
    for (const change of simulateDataChanges) {
      setTimeout(() => {
        injectTestData(triggerId, change.data);
      }, change.at);
    }
  }

  // Wait for test duration
  await sleep(testDuration);

  pollListener.stop();
  execListener.stop();

  // Analyze results
  const expectedPolls = Math.floor(testDuration / interval);
  const actualPolls = pollEvents.length;

  return {
    interval,
    testDuration,
    expectedPolls,
    actualPolls,
    pollAccuracy: (actualPolls / expectedPolls) * 100,
    averageInterval: calculateAverageInterval(pollEvents),
    executionsTriggered: triggeredExecutions.length,
    deduplicationWorking: checkDeduplication(triggeredExecutions),
    pollEvents
  };
}

// Check if deduplication is working
function checkDeduplication(executions: Execution[]): boolean {
  const processedIds = new Set();

  for (const exec of executions) {
    const itemIds = exec.data?.resultData?.runData?.Trigger?.[0]?.data?.main?.[0]
      ?.map(item => item.json?.id);

    if (itemIds) {
      for (const id of itemIds) {
        if (processedIds.has(id)) {
          return false; // Duplicate found
        }
        processedIds.add(id);
      }
    }
  }

  return true;
}

Event Trigger Testing

// Test event-driven triggers
async function testEventTrigger(triggerId: string, eventConfig: EventTestConfig): Promise<EventTestResult> {
  const { eventType, testEvents, timeout } = eventConfig;

  const results: EventResult[] = [];

  for (const testEvent of testEvents) {
    // Emit test event
    const startTime = Date.now();
    await emitTestEvent(eventType, testEvent.payload);

    // Wait for trigger
    try {
      const execution = await waitForTrigger(triggerId, timeout);

      results.push({
        eventType: testEvent.type,
        triggered: true,
        latency: Date.now() - startTime,
        payloadReceived: execution.data?.inputData
      });
    } catch (error) {
      results.push({
        eventType: testEvent.type,
        triggered: false,
        error: error.message
      });
    }
  }

  return {
    eventType,
    testsRun: testEvents.length,
    triggered: results.filter(r => r.triggered).length,
    averageLatency: average(results.filter(r => r.triggered).map(r => r.latency)),
    results
  };
}

Trigger Response Testing

// Test trigger response modes
async function testTriggerResponses(webhookUrl: string): Promise<ResponseTestResult> {
  // Test immediate response
  const immediateStart = Date.now();
  const immediateResponse = await fetch(webhookUrl, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: '{"test": "immediate"}'
  });
  const immediateTime = Date.now() - immediateStart;

  // Test with workflow execution
  const workflowStart = Date.now();
  const workflowResponse = await fetch(`${webhookUrl}?waitForResponse=true`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: '{"test": "workflow"}'
  });
  const workflowTime = Date.now() - workflowStart;

  return {
    immediateResponse: {
      status: immediateResponse.status,
      time: immediateTime,
      body: await immediateResponse.text()
    },
    workflowResponse: {
      status: workflowResponse.status,
      time: workflowTime,
      body: await workflowResponse.text()
    },
    responseMode: workflowTime > immediateTime + 100 ? 'workflow' : 'immediate'
  };
}

Test Scenarios

Webhook Scenarios:
  - name: Valid JSON POST
    method: POST
    payload: {"event": "test"}
    expected: 200 OK

  - name: Invalid JSON
    method: POST
    payload: "not valid json"
    expected: 400 Bad Request

  - name: Missing auth
    method: POST
    headers: {}
    expected: 401 Unauthorized

  - name: Large payload
    method: POST
    payload: [10MB of data]
    expected: 413 Payload Too Large

Schedule Scenarios:
  - name: Every 5 minutes
    cron: "*/5 * * * *"
    verify: 12 executions per hour

  - name: Weekdays at 9 AM
    cron: "0 9 * * 1-5"
    verify: 5 executions per week

Polling Scenarios:
  - name: 1 minute interval
    interval: 60000
    verify: ~60 polls per hour

  - name: Deduplication
    interval: 60000
    inject_duplicate: true
    verify: No duplicate processing

Related Skills


Remember

n8n triggers are the entry points to workflows. Testing requires:

  • Webhook: Payload handling, auth, HTTP methods
  • Schedule: Cron accuracy, timezone handling
  • Polling: Interval accuracy, deduplication
  • Event: Event handling, filtering

Key patterns: Test with various payloads (valid, invalid, edge cases). Verify authentication enforcement. Check response times and reliability over time.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

29.57%
按下载量换算172

Antigravity

24.21%
按下载量换算141

Gemini CLI

15.69%
按下载量换算91

OpenCode

13.51%
按下载量换算79

windsurf

7.96%
按下载量换算46

Codex

3.55%
按下载量换算21

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。

来源信息

继续浏览同类 Skills