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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ec1bfaf651
commit
2cf9eeb224
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {transform} from '@babel/core';
|
import {transform} from '@babel/core';
|
||||||
import electronRequiresMainPlugin = require('../electron-requires-main');
|
const electronRequiresMainPlugin = require('../electron-requires-main');
|
||||||
|
|
||||||
const babelOptions = {
|
const babelOptions = {
|
||||||
ast: true,
|
ast: true,
|
||||||
|
|||||||
@@ -8,12 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import {mocked} from 'ts-jest/utils';
|
|
||||||
import getPluginDetails from '../getPluginDetails';
|
import getPluginDetails from '../getPluginDetails';
|
||||||
|
|
||||||
jest.mock('fs-extra');
|
|
||||||
const fsMock = mocked(fs, true);
|
|
||||||
|
|
||||||
test('getPluginDetailsV1', async () => {
|
test('getPluginDetailsV1', async () => {
|
||||||
const pluginV1 = {
|
const pluginV1 = {
|
||||||
name: 'flipper-plugin-test',
|
name: 'flipper-plugin-test',
|
||||||
@@ -22,7 +18,8 @@ test('getPluginDetailsV1', async () => {
|
|||||||
main: 'src/index.tsx',
|
main: 'src/index.tsx',
|
||||||
gatekeeper: 'GK_flipper_plugin_test',
|
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');
|
const details = await getPluginDetails('./plugins/flipper-plugin-test');
|
||||||
expect(details).toMatchInlineSnapshot(`
|
expect(details).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
@@ -52,7 +49,8 @@ test('getPluginDetailsV2', async () => {
|
|||||||
flipperBundlerEntry: 'src/index.tsx',
|
flipperBundlerEntry: 'src/index.tsx',
|
||||||
gatekeeper: 'GK_flipper_plugin_test',
|
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');
|
const details = await getPluginDetails('./plugins/flipper-plugin-test');
|
||||||
expect(details).toMatchInlineSnapshot(`
|
expect(details).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
@@ -82,7 +80,8 @@ test('id used as title if the latter omited', async () => {
|
|||||||
flipperBundlerEntry: 'src/index.tsx',
|
flipperBundlerEntry: 'src/index.tsx',
|
||||||
gatekeeper: 'GK_flipper_plugin_test',
|
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');
|
const details = await getPluginDetails('./plugins/flipper-plugin-test');
|
||||||
expect(details).toMatchInlineSnapshot(`
|
expect(details).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
@@ -111,7 +110,8 @@ test('name without "flipper-plugin-" prefix is used as title if the latter omite
|
|||||||
flipperBundlerEntry: 'src/index.tsx',
|
flipperBundlerEntry: 'src/index.tsx',
|
||||||
gatekeeper: 'GK_flipper_plugin_test',
|
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');
|
const details = await getPluginDetails('./plugins/flipper-plugin-test');
|
||||||
expect(details).toMatchInlineSnapshot(`
|
expect(details).toMatchInlineSnapshot(`
|
||||||
Object {
|
Object {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ async function getPluginDetailsV1(
|
|||||||
dir: pluginDir,
|
dir: pluginDir,
|
||||||
name: packageJson.name,
|
name: packageJson.name,
|
||||||
version: packageJson.version,
|
version: packageJson.version,
|
||||||
main: path.join('dist', 'index.js'),
|
main: 'dist/index.js',
|
||||||
source: packageJson.main,
|
source: packageJson.main,
|
||||||
id: packageJson.name,
|
id: packageJson.name,
|
||||||
gatekeeper: packageJson.gatekeeper,
|
gatekeeper: packageJson.gatekeeper,
|
||||||
|
|||||||
Reference in New Issue
Block a user