You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `NangoSyncMock` and `NangoActionMock` classes automatically load your saved mocks:
317
+
The `NangoSyncMock` and `NangoActionMock` classes automatically load your saved mocks from the `.test.json` file:
334
318
335
-
1.**API requests** are intercepted and return saved mock responses
336
-
2.**Input data** is loaded from `input.json`(for actions)
337
-
3.**Expected outputs** are loaded from the appropriate mock files
338
-
4.**Tests compare** actual outputs against expected outputs
319
+
1.**API requests** are intercepted and return saved mock responses from the `api` section.
320
+
2.**Input data** is loaded from the `input` property (for actions).
321
+
3.**Expected outputs** are loaded from the `output` property.
322
+
4.**Tests compare** actual outputs against expected outputs.
339
323
340
324
This means:
341
325
- Tests run **instantly** (no API calls)
342
326
- Tests are **deterministic** (same input = same output)
343
327
- Tests work **offline**
344
328
329
+
### Migrating from the old format
330
+
331
+
If you have tests using the old multi-file mock format, you can automatically migrate them to the new unified format.
332
+
333
+
Set the `MIGRATE_MOCKS` environment variable to `true` and run your tests:
334
+
335
+
```bash
336
+
MIGRATE_MOCKS=true npm test
337
+
```
338
+
339
+
This will:
340
+
1. Run your tests using the old mock files.
341
+
2. Intercept all mock data accessed during the test run.
342
+
3. Save the data into a new `.test.json` file.
343
+
4. The old mock directory can then be safely deleted.
344
+
345
+
> **Note:** This migration tool works by intercepting the mock data loaded by your existing tests. It requires that your tests are using the standard Nango mock utilities (`NangoSyncMock` or `NangoActionMock`) imported from `nango/test`.
346
+
345
347
### Running tests
346
348
347
349
```bash
@@ -380,7 +382,7 @@ export default defineConfig({
380
382
The `vitest.setup.ts` file makes Nango mocks available globally:
0 commit comments