testing-n8n-testing

majiayu000 的头像作者 majiayu000

使用 Jest 测试 n8n 节点、用于 HTTP 模拟的 nock 以及使用 npm link 的本地测试工作流程。在 __tests__ 文件夹中编写测试文件、使用 nock 模拟 HTTP 请求、创建模拟 IExecuteFunctions 上下文、测试辅助函数、设置黄金文件测试、发布前运行 linter 或在 n8n UI 中本地测试节点时,请使用此技能。在组织测试文件、模拟外部 API、验证节点执行输出或遵循预发布清单时应用。

📖 中文导读:使用 Jest 测试 n8n 节点、用于 HTTP 模拟的 nock 以及使用 npm link 的本地测试工作流程。在 __tests__ 文件夹中编写测试文件、使用 nock 模拟 HTTP 请求、创建模拟 IExecuteFunctions 上下文、测试辅助函数、设置黄金文件测试、发布前运行 linter 或在 n8n UI 中本地测试节点时,请使用此技能。在组织测试文件、模拟外部 API、验证节点执行输出或遵循预发布清单时应用。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。

name: Testing N8n Testing description: Test n8n nodes using Jest, nock for HTTP mocking, and local testing workflows with npm link. Use this skill when writing test files in tests folders, mocking HTTP requests with nock, creating mock IExecuteFunctions contexts, testing helper functions, setting up golden file tests, running the linter before publishing, or locally testing nodes in the n8n UI. Apply when organizing test files, mocking external APIs, validating node execution output, or following the pre-publish checklist.

When to use this skill:

  • When creating test files in tests/ folders
  • When writing Jest test suites for n8n nodes
  • When mocking HTTP requests with nock (beforeAll, afterEach, afterAll patterns)
  • When testing helper functions for data formatting
  • When creating mock IExecuteFunctions for node execution tests
  • When verifying node output against expected results
  • When testing API error handling (401, 404, 429 responses)
  • When setting up golden file tests for complex output
  • When linking nodes locally for manual testing (npm link)
  • When using n8n dev mode with hot reload
  • When running npm run lint before publishing
  • When following the pre-publish checklist (tests pass, build succeeds, manual testing)
  • When testing credentials save and validation in n8n UI

Testing N8n Testing

This Skill provides Claude Code with specific guidance on how to adhere to coding standards as they relate to how it should handle testing n8n testing.

Instructions

For details, refer to the information provided in this file: testing n8n testing