workflows.fit
Back to n8n workflows
n8n template$19By Varritech

Automatic jest test generation for GitHub PRs with dual AI review

Workflow: Automatic Unit Test Creator from GitHub πŸ—οΈ Architecture Overview This workflow listens for GitHub pull-request events, analyzes changed React/TypeScript files, auto-generates Jest tests via AI, has them rev...

DevelopmentCore NodesAILangchainGithubHttp RequestCodeGithub Tool
Open checkout
Loading interactive preview...

Template notes

Workflow: Automatic Unit Test Creator from GitHub

πŸ—οΈ Architecture Overview This workflow listens for GitHub pull-request events, analyzes changed React/TypeScript files, auto-generates Jest tests via AI, has them reviewed by a second AI pass, and posts suggestions back as PR comments:

1. GitHub Webhook β†’ PR opened or updated 2. Fetch & Diff β†’ Retrieve raw diff of changed files 3. Filter & Split β†’ Isolate .tsx files & their diffs 4. Fetch File Contents β†’ Provide full context for tests 5. Test Maker Agent β†’ Generate Jest tests for diff hunks 6. Code Reviewer Agent β†’ Refine tests for style & edge-cases 7. Post PR Comment β†’ Sends suggested tests back to GitHub

πŸ“¦ Node-by-Node Breakdown

mermaid flowchart LR A[Webhook: /github/pr-events] --> B[GitHub: Get PR] B --> C[Function: Parse diffurl + owner/repo] C --> D[HTTP Request: GET diffurl] D --> E[Function: Split on "diff --git"] E --> F[Filter: /\.tsx$/] F --> G[GitHub: Get File Contents] G --> H[Test Maker Agent] H --> I[Code Reviewer Agent] I --> J[Function: Build Comment Payload] J --> K[HTTP Request: POST to PR Comments]

Webhook: GitHub PR Events - Type: HTTP Webhook (/webhook/github/pr-events) - Subscribed Events: pullrequest.opened, pullrequest.synchronize

GitHub: Get PR - Node: GitHub - Action: "Get Pull Request" - Inputs: owner, repo, pullnumber

Function: Parse diffurl + owner/repo - Extracts: - diffurl (e.g. …/pulls/123.diff) - owner, repo, mergecommitsha