Skip to content

Conversation

@agusayerza
Copy link
Contributor

@agusayerza agusayerza commented Dec 19, 2025

This PR introduces a unified structure for test mocks, consolidating scattered JSON files into a single .test.json file per test suite.
Changes include:

  • Updated nango dryrun --save to generate the new unified mock format.
  • Implemented ResponseCollector to aggregate API calls during dry runs.
  • Updated NangoActionMock and NangoSyncMock in nango/test to support the new format.
  • Added a migration path: Running MIGRATE_MOCKS=true npm test will record legacy mock usage and generate the new unified file automatically.
  • Updated testing documentation to reflect the new structure

Note: We need to follow up in the integration-templates repo to update vitest.setup.ts to import from nango/test instead of using local mock implementations, and support migration that way instead of having its own custom migration logic.

NAN-4463

Testing instructions:

  1. Run nango dryrun <name> <connectionId> --save and verify a single .test.json is created.
  2. Run npm test to verify tests pass with the new format.
  3. (Optional) In a project with legacy mocks, run MIGRATE_MOCKS=true npm test and verify the new mock file is generated.

This change will updates the NangoActionMock and NangoSyncMock to match the integration-templates implementation, allowing us to replace the logic on integration-templates once this is landed


ResponseCollector now captures not just API calls but also connection metadata and batched operations, and the Vitest helpers can seamlessly work with unified fixtures, legacy recordings, or new on-the-fly captures to smooth the migration.

Affected Areas

• packages/cli/lib/services/dryrun.service.ts
• packages/cli/lib/services/response-collector.service.ts
• packages/cli/lib/testMocks/utils.ts
• docs/implementation-guides/building-integrations/testing.mdx
• packages/cli/package.json


This summary was automatically generated by @propel-code-bot

@linear
Copy link

linear bot commented Dec 19, 2025

@my-senior-dev-pr-review
Copy link

my-senior-dev-pr-review bot commented Dec 19, 2025

🤖 My Senior Dev — Analysis Complete

👤 For @agusayerza

📁 Expert in packages/ (20 edits) • ⚡ 4th PR this month

View your contributor analytics →


📊 7 files reviewed • 2 need attention

⚠️ Needs Attention:

  • docs/implementation-guides/building-integrations/testing.mdx — Significant changes to the mock file structure and migration process necessitate careful examination.

🚀 Open Interactive Review →

The full interface unlocks features not available in GitHub:

  • 💬 AI Chat — Ask questions on any file, get context-aware answers
  • 🔍 Smart Hovers — See symbol definitions and usage without leaving the diff
  • 📚 Code Archeology — Understand how files evolved over time (/archeology)
  • 🎯 Learning Insights — See how this PR compares to similar changes

💬 Chat here: @my-senior-dev explain this change — or try @chaos-monkey @security-auditor @optimizer @skeptic @junior-dev

📖 View all 12 personas & slash commands

You can interact with me by mentioning @my-senior-dev in any comment:

In PR comments or on any line of code:

  • Ask questions about the code or PR
  • Request explanations of specific changes
  • Get suggestions for improvements

Slash commands:

  • /help — Show all available commands
  • /archeology — See the history and evolution of changed files
  • /profile — Performance analysis and suggestions
  • /expertise — Find who knows this code best
  • /personas — List all available AI personas

AI Personas (mention to get their perspective):

Persona Focus
@chaos-monkey 🐵 Edge cases & failure scenarios
@skeptic 🤨 Challenge assumptions
@optimizer Performance & efficiency
@security-auditor 🔒 Security vulnerabilities
@accessibility-advocate Inclusive design
@junior-dev 🌱 Simple explanations
@tech-debt-collector 💳 Code quality & shortcuts
@ux-champion 🎨 User experience
@devops-engineer 🚀 Deployment & scaling
@documentation-nazi 📚 Documentation gaps
@legacy-whisperer 🏛️ Working with existing code
@test-driven-purist Testing & TDD

For the best experience, view this PR on myseniordev.com — includes AI chat, file annotations, and interactive reviews.

@agusayerza agusayerza force-pushed the agus/NAN-4463/mock-structure-refactor/update-docs branch from 024943e to 07a1f7c Compare December 19, 2025 15:21
@agusayerza agusayerza force-pushed the agus/NAN-4463/mock-structure-refactor/update-docs branch from 07a1f7c to 6cead33 Compare December 19, 2025 18:42
@agusayerza agusayerza force-pushed the agus/NAN-4463/mock-structure-refactor/update-docs branch from 6cead33 to 70da92c Compare December 19, 2025 18:50
@agusayerza agusayerza force-pushed the agus/NAN-4463/mock-structure-refactor/update-docs branch from 70da92c to a9b81ed Compare December 22, 2025 14:56
@agusayerza agusayerza force-pushed the agus/NAN-4463/mock-structure-refactor/update-docs branch from a9b81ed to dec42a9 Compare December 22, 2025 17:32
@agusayerza agusayerza force-pushed the agus/NAN-4463/mock-structure-refactor/update-docs branch from dec42a9 to f3ac9c1 Compare December 22, 2025 17:46
@agusayerza agusayerza requested a review from a team December 23, 2025 13:17
@agusayerza agusayerza marked this pull request as ready for review December 23, 2025 13:17

let requestData = call.requestIdentity.data;
if (typeof requestData === 'string') {
requestData = JSON.parse(requestData);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can the parsing throw?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might, if the request isn't json. I have wrapped it with a try/catch

import { parse } from './config.service.js';
import { DiagnosticsMonitor, formatDiagnostics } from './diagnostics-monitor.service.js';
import { loadSchemaJson } from './model.service.js';
import * as responseSaver from './response-saver.service.js';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can the 'response-saver.service.ts` file be deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}

private computeRequestIdentity(config: AxiosRequestConfig): { requestIdentity: RequestIdentity; requestIdentityHash: string } {
const method = config.method?.toUpperCase() || 'GET';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previous logic was using lowercase. Isn't using uppercase changing the identity hash and making it incompatible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, although it wouldn't really matter as this is for new test generations, and when parsing the request at test runtime, we still LowerCase it. Regardless, I changed it back to use lowercase as there is no reason to modify our behaviour.

ptrtht added a commit to ptrtht/nango that referenced this pull request Jan 5, 2026
Updated the action implementation guide to fix a typo in the code example, changing '<ATION-NAME>' to '<ACTION-NAME>''
github-merge-queue bot pushed a commit that referenced this pull request Jan 6, 2026
Updated the action implementation guide to fix a typo in the code
example, changing '<ATION-NAME>' to '<ACTION-NAME>''

It's just a typo in the docs that was bugging me for days.
@agusayerza agusayerza force-pushed the agus/NAN-4463/mock-structure-refactor/update-docs branch from f3ac9c1 to 97b8043 Compare January 12, 2026 16:37
@agusayerza agusayerza force-pushed the agus/NAN-4463/mock-structure-refactor/update-docs branch from 97b8043 to be82deb Compare January 12, 2026 17:02
hassan254-prog pushed a commit that referenced this pull request Jan 12, 2026
Updated the action implementation guide to fix a typo in the code
example, changing '<ATION-NAME>' to '<ACTION-NAME>''

It's just a typo in the docs that was bugging me for days.
@agusayerza agusayerza force-pushed the agus/NAN-4463/mock-structure-refactor/update-docs branch from be82deb to 4a75028 Compare January 13, 2026 15:55
@agusayerza agusayerza requested a review from TBonnin January 13, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants