From 5320015776fe8b1a69f9900114259989deb5dd0e Mon Sep 17 00:00:00 2001 From: bizzguy Date: Mon, 1 Feb 2021 10:21:21 -0800 Subject: [PATCH] Fix mock export file format (#1872) Summary: Provide a more robust technique for exporting the mocks to a file. The current technique for exporting mocks to a file seems to fail under some scenarios. The correct format is an array of objects: ``` [ { "requestUrl": "https://api.github.com/repos/facebook/yoga", "requestMethod": "GET", ``` However, the following format is sometimes exported instead: ``` { "10": { "requestUrl": "https://demo9512366.mockable.io/SonarPost", ``` Using `Object.values` provides a more robust technique that has been successful during subsequent testing. ## Changelog Network Plugin - new technique for exporting mocks Pull Request resolved: https://github.com/facebook/flipper/pull/1872 Test Plan: Create mocks in the network plugin Export mocks Manually examine file for correct format Import mocks and verify that the file has been imported correctly Reviewed By: nikoant Differential Revision: D26172954 Pulled By: mweststrate fbshipit-source-id: bdfa3ba7dfe656f30ef17df001fc83dd8ea18ece --- desktop/plugins/network/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/plugins/network/index.tsx b/desktop/plugins/network/index.tsx index bc15b3443..c90f95a40 100644 --- a/desktop/plugins/network/index.tsx +++ b/desktop/plugins/network/index.tsx @@ -445,7 +445,7 @@ export function plugin(client: PluginClient) { } fs.writeFile( file, - JSON.stringify(routes.get(), null, 2), + JSON.stringify(Object.values(routes.get()), null, 2), 'utf8', (err) => { if (err) {