From 2cf9eeb22455ec2e0d6f4f2652441561dba83906 Mon Sep 17 00:00:00 2001 From: Anton Nikolaev Date: Tue, 21 Apr 2020 01:38:19 -0700 Subject: [PATCH] Fix the tests failing on Windows (#1036) Summary: Pull Request resolved: https://github.com/facebook/flipper/pull/1036 Fixed the tests failing on Windows Reviewed By: passy Differential Revision: D21144338 fbshipit-source-id: 3b76a5d42a764a2eec89e26ee0ca94bd739e46bd --- .../src/__tests__/electron-requires-main.node.ts | 2 +- .../src/__tests__/getPluginDetails.node.ts | 16 ++++++++-------- desktop/pkg-lib/src/getPluginDetails.ts | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/desktop/babel-transformer/src/__tests__/electron-requires-main.node.ts b/desktop/babel-transformer/src/__tests__/electron-requires-main.node.ts index df10398e1..53da1b960 100644 --- a/desktop/babel-transformer/src/__tests__/electron-requires-main.node.ts +++ b/desktop/babel-transformer/src/__tests__/electron-requires-main.node.ts @@ -8,7 +8,7 @@ */ import {transform} from '@babel/core'; -import electronRequiresMainPlugin = require('../electron-requires-main'); +const electronRequiresMainPlugin = require('../electron-requires-main'); const babelOptions = { ast: true, diff --git a/desktop/pkg-lib/src/__tests__/getPluginDetails.node.ts b/desktop/pkg-lib/src/__tests__/getPluginDetails.node.ts index dd9d2c9fd..309d1db6a 100644 --- a/desktop/pkg-lib/src/__tests__/getPluginDetails.node.ts +++ b/desktop/pkg-lib/src/__tests__/getPluginDetails.node.ts @@ -8,12 +8,8 @@ */ import fs from 'fs-extra'; -import {mocked} from 'ts-jest/utils'; import getPluginDetails from '../getPluginDetails'; -jest.mock('fs-extra'); -const fsMock = mocked(fs, true); - test('getPluginDetailsV1', async () => { const pluginV1 = { name: 'flipper-plugin-test', @@ -22,7 +18,8 @@ test('getPluginDetailsV1', async () => { main: 'src/index.tsx', gatekeeper: 'GK_flipper_plugin_test', }; - fsMock.readJson.mockImplementation(() => pluginV1); + jest.mock('fs-extra', () => jest.fn()); + fs.readJson = jest.fn().mockImplementation(() => pluginV1); const details = await getPluginDetails('./plugins/flipper-plugin-test'); expect(details).toMatchInlineSnapshot(` Object { @@ -52,7 +49,8 @@ test('getPluginDetailsV2', async () => { flipperBundlerEntry: 'src/index.tsx', gatekeeper: 'GK_flipper_plugin_test', }; - fsMock.readJson.mockImplementation(() => pluginV2); + jest.mock('fs-extra', () => jest.fn()); + fs.readJson = jest.fn().mockImplementation(() => pluginV2); const details = await getPluginDetails('./plugins/flipper-plugin-test'); expect(details).toMatchInlineSnapshot(` Object { @@ -82,7 +80,8 @@ test('id used as title if the latter omited', async () => { flipperBundlerEntry: 'src/index.tsx', gatekeeper: 'GK_flipper_plugin_test', }; - fsMock.readJson.mockImplementation(() => pluginV2); + jest.mock('fs-extra', () => jest.fn()); + fs.readJson = jest.fn().mockImplementation(() => pluginV2); const details = await getPluginDetails('./plugins/flipper-plugin-test'); expect(details).toMatchInlineSnapshot(` Object { @@ -111,7 +110,8 @@ test('name without "flipper-plugin-" prefix is used as title if the latter omite flipperBundlerEntry: 'src/index.tsx', gatekeeper: 'GK_flipper_plugin_test', }; - fsMock.readJson.mockImplementation(() => pluginV2); + jest.mock('fs-extra', () => jest.fn()); + fs.readJson = jest.fn().mockImplementation(() => pluginV2); const details = await getPluginDetails('./plugins/flipper-plugin-test'); expect(details).toMatchInlineSnapshot(` Object { diff --git a/desktop/pkg-lib/src/getPluginDetails.ts b/desktop/pkg-lib/src/getPluginDetails.ts index acbf59694..1e8ca6439 100644 --- a/desktop/pkg-lib/src/getPluginDetails.ts +++ b/desktop/pkg-lib/src/getPluginDetails.ts @@ -40,7 +40,7 @@ async function getPluginDetailsV1( dir: pluginDir, name: packageJson.name, version: packageJson.version, - main: path.join('dist', 'index.js'), + main: 'dist/index.js', source: packageJson.main, id: packageJson.name, gatekeeper: packageJson.gatekeeper,