From 9604e33f3a3d0c340d7581c158fd5617cde1f1b6 Mon Sep 17 00:00:00 2001 From: Anton Nikolaev Date: Mon, 8 Jun 2020 08:47:29 -0700 Subject: [PATCH] Fix snapshot tests failing on windows (#1229) Summary: Pull Request resolved: https://github.com/facebook/flipper/pull/1229 Fix snapshot tests which are currently failing on Windows. Reviewed By: mweststrate Differential Revision: D21928445 fbshipit-source-id: 85ad79f5e01204fedecbef6828c978f76c0380f8 --- .../src/__tests__/getPluginDetails.node.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/desktop/plugin-lib/src/__tests__/getPluginDetails.node.ts b/desktop/plugin-lib/src/__tests__/getPluginDetails.node.ts index 3b6d49208..63be8a388 100644 --- a/desktop/plugin-lib/src/__tests__/getPluginDetails.node.ts +++ b/desktop/plugin-lib/src/__tests__/getPluginDetails.node.ts @@ -31,6 +31,8 @@ test('getPluginDetailsV1', async () => { jest.mock('fs-extra', () => jest.fn()); fs.readJson = jest.fn().mockImplementation(() => pluginV1); const details = await getPluginDetails(pluginPath); + details.dir = normalizeOnWindows(details.dir); + details.entry = normalizeOnWindows(details.entry); expect(details).toMatchInlineSnapshot(` Object { "bugs": undefined, @@ -66,6 +68,8 @@ test('getPluginDetailsV2', async () => { jest.mock('fs-extra', () => jest.fn()); fs.readJson = jest.fn().mockImplementation(() => pluginV2); const details = await getPluginDetails(pluginPath); + details.dir = normalizeOnWindows(details.dir); + details.entry = normalizeOnWindows(details.entry); expect(details).toMatchInlineSnapshot(` Object { "bugs": undefined, @@ -101,6 +105,8 @@ test('id used as title if the latter omited', async () => { jest.mock('fs-extra', () => jest.fn()); fs.readJson = jest.fn().mockImplementation(() => pluginV2); const details = await getPluginDetails(pluginPath); + details.dir = normalizeOnWindows(details.dir); + details.entry = normalizeOnWindows(details.entry); expect(details).toMatchInlineSnapshot(` Object { "bugs": undefined, @@ -135,6 +141,8 @@ test('name without "flipper-plugin-" prefix is used as title if the latter omite jest.mock('fs-extra', () => jest.fn()); fs.readJson = jest.fn().mockImplementation(() => pluginV2); const details = await getPluginDetails(pluginPath); + details.dir = normalizeOnWindows(details.dir); + details.entry = normalizeOnWindows(details.entry); expect(details).toMatchInlineSnapshot(` Object { "bugs": undefined, @@ -155,3 +163,11 @@ test('name without "flipper-plugin-" prefix is used as title if the latter omite } `); }); + +const normalizeOnWindows = (path: string): string => { + if (process.platform === 'win32') { + path = path.replace(/\\/g, '/'); + path = path.substring(path.indexOf('/')); + } + return path; +};