-
Notifications
You must be signed in to change notification settings - Fork 612
feat(cli): Unified mock format and migration support #5183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat(cli): Unified mock format and migration support #5183
Conversation
🤖 My Senior Dev — Analysis Complete👤 For @agusayerza📁 Expert in View your contributor analytics → 📊 7 files reviewed • 2 need attention
🚀 Open Interactive Review →The full interface unlocks features not available in GitHub:
💬 Chat here: 📖 View all 12 personas & slash commandsYou can interact with me by mentioning In PR comments or on any line of code:
Slash commands:
AI Personas (mention to get their perspective):
For the best experience, view this PR on myseniordev.com — includes AI chat, file annotations, and interactive reviews. |
024943e to
07a1f7c
Compare
07a1f7c to
6cead33
Compare
6cead33 to
70da92c
Compare
70da92c to
a9b81ed
Compare
a9b81ed to
dec42a9
Compare
dec42a9 to
f3ac9c1
Compare
|
|
||
| let requestData = call.requestIdentity.data; | ||
| if (typeof requestData === 'string') { | ||
| requestData = JSON.parse(requestData); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can the parsing throw?
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Updated the action implementation guide to fix a typo in the code example, changing '<ATION-NAME>' to '<ACTION-NAME>''
f3ac9c1 to
97b8043
Compare
97b8043 to
be82deb
Compare
be82deb to
4a75028
Compare
4a75028 to
8e60791
Compare
This PR introduces a unified structure for test mocks, consolidating scattered JSON files into a single .test.json file per test suite.
Changes include:
nango dryrun --saveto generate the new unified mock format.ResponseCollectorto aggregate API calls during dry runs.NangoActionMockandNangoSyncMockinnango/testto support the new format.MIGRATE_MOCKS=true npm testwill record legacy mock usage and generate the new unified file automatically.NAN-4463
Testing instructions:
nango dryrun <name> <connectionId> --saveand verify a single.test.jsonis created.npm testto verify tests pass with the new format.This change will updates the
NangoActionMockandNangoSyncMockto match theintegration-templatesimplementation, allowing us to replace the logic on integration-templates once this is landedResponseCollector 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