Jest update v26.6.3 -> v29.5.1

Summary:
^

Basically, update Jest and fix any raised issues. Mainly:
- Update necessary dependencies
- Update snapshots
- `useFakeTimers` caused a few issues which meant that the way we hook into the performance object had to be tweaked. The main code change is: `//fbsource/xplat/sonar/desktop/scripts/jest-setup-after.tsx`
- `mocked` -> `jest.mocked`

Changelog: Update Jest to v29.5.1

Reviewed By: antonk52

Differential Revision: D46319818

fbshipit-source-id: d218ca8f7e43abac6b00844953ddeb7f4e1010a2
This commit is contained in:
Lorenzo Blasa
2023-05-31 14:19:29 -07:00
committed by Facebook GitHub Bot
parent 94cb8935b2
commit 6430403da0
40 changed files with 1721 additions and 1787 deletions

View File

@@ -50,8 +50,8 @@ test('test shared data structure', () => {
expect(res.x).not.toBe(res.y); expect(res.x).not.toBe(res.y);
// @ts-ignore // @ts-ignore
expect(console.warn.mock.calls).toMatchInlineSnapshot(` expect(console.warn.mock.calls).toMatchInlineSnapshot(`
Array [ [
Array [ [
"Duplicate value, object lives at path '.y', but also at path '.x': '[object Object]'. This might not behave correct after import and lead to unnecessary big exports.", "Duplicate value, object lives at path '.y', but also at path '.x': '[object Object]'. This might not behave correct after import and lead to unnecessary big exports.",
], ],
] ]
@@ -231,7 +231,7 @@ test.unix(
() => { () => {
const date = new Date(2021, 1, 29, 10, 31, 7, 205); const date = new Date(2021, 1, 29, 10, 31, 7, 205);
expect(makeShallowSerializable(date)).toMatchInlineSnapshot(` expect(makeShallowSerializable(date)).toMatchInlineSnapshot(`
Object { {
"__flipper_object_type__": "Date", "__flipper_object_type__": "Date",
"data": 1614555067205, "data": 1614555067205,
} }

View File

@@ -27,7 +27,7 @@ test('Correct top level API exposed', () => {
// Note, all `exposedAPIs` should be documented in `flipper-plugin.mdx` // Note, all `exposedAPIs` should be documented in `flipper-plugin.mdx`
expect(exposedAPIs.sort()).toMatchInlineSnapshot(` expect(exposedAPIs.sort()).toMatchInlineSnapshot(`
Array [ [
"CodeBlock", "CodeBlock",
"DataDescription", "DataDescription",
"DataFormatter", "DataFormatter",
@@ -83,7 +83,7 @@ test('Correct top level API exposed', () => {
`); `);
expect(exposedTypes.sort()).toMatchInlineSnapshot(` expect(exposedTypes.sort()).toMatchInlineSnapshot(`
Array [ [
"Atom", "Atom",
"AtomPersistentStorage", "AtomPersistentStorage",
"CrashLog", "CrashLog",

View File

@@ -180,8 +180,8 @@ test('a plugin can receive messages', async () => {
sendEvent('inc', {delta: 2}); sendEvent('inc', {delta: 2});
expect(instance.state.get().count).toBe(2); expect(instance.state.get().count).toBe(2);
expect(exportState()).toMatchInlineSnapshot(` expect(exportState()).toMatchInlineSnapshot(`
Object { {
"counter": Object { "counter": {
"count": 2, "count": 2,
}, },
} }
@@ -268,7 +268,7 @@ test('plugins cannot use a persist key twice', async () => {
}, },
}); });
}).toThrowErrorMatchingInlineSnapshot( }).toThrowErrorMatchingInlineSnapshot(
`"Some other state is already persisting with key \\"test\\""`, `"Some other state is already persisting with key "test""`,
); );
}); });
@@ -352,8 +352,8 @@ test('plugins can handle import errors', async () => {
).instance; ).instance;
// @ts-ignore // @ts-ignore
expect(console.error.mock.calls).toMatchInlineSnapshot(` expect(console.error.mock.calls).toMatchInlineSnapshot(`
Array [ [
Array [ [
"An error occurred when importing data for plugin 'TestPlugin': 'Error: Oops", "An error occurred when importing data for plugin 'TestPlugin': 'Error: Oops",
[Error: Oops], [Error: Oops],
], ],

View File

@@ -42,8 +42,8 @@ test('it can start a plugin and lifecycle events', () => {
expect(instance.x.get()).toEqual({x: 2}); expect(instance.x.get()).toEqual({x: 2});
expect(instance.y.get()).toEqual(true); expect(instance.y.get()).toEqual(true);
expect(getStorageSnapshot()).toMatchInlineSnapshot(` expect(getStorageSnapshot()).toMatchInlineSnapshot(`
Object { {
"flipper:TestPlugin:atom:x": "{ \\"x\\": 2 }", "flipper:TestPlugin:atom:x": "{ "x": 2 }",
} }
`); `);
@@ -52,8 +52,8 @@ test('it can start a plugin and lifecycle events', () => {
}); });
instance.y.set(false); instance.y.set(false);
expect(getStorageSnapshot()).toMatchInlineSnapshot(` expect(getStorageSnapshot()).toMatchInlineSnapshot(`
Object { {
"flipper:TestPlugin:atom:x": "{\\"x\\":3}", "flipper:TestPlugin:atom:x": "{"x":3}",
"flipper:TestPlugin:atom:y": "false", "flipper:TestPlugin:atom:y": "false",
} }
`); `);

View File

@@ -25,13 +25,13 @@ test('default formatter', () => {
expect(DataFormatter.format({hello: 'world'})).toMatchInlineSnapshot(` expect(DataFormatter.format({hello: 'world'})).toMatchInlineSnapshot(`
"{ "{
\\"hello\\": \\"world\\" "hello": "world"
}" }"
`); `);
expect(DataFormatter.format({hello: ['world']})).toMatchInlineSnapshot(` expect(DataFormatter.format({hello: ['world']})).toMatchInlineSnapshot(`
"{ "{
\\"hello\\": [ "hello": [
\\"world\\" "world"
] ]
}" }"
`); `);
@@ -39,8 +39,8 @@ test('default formatter', () => {
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"[ "[
[ [
\\"hello\\", "hello",
\\"world\\" "world"
] ]
]" ]"
`); `);
@@ -48,8 +48,8 @@ test('default formatter', () => {
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"[ "[
[ [
\\"hello\\", "hello",
\\"world\\" "world"
] ]
]" ]"
`); `);
@@ -85,7 +85,7 @@ test('linkify formatter', () => {
// verify fallback // verify fallback
expect(linkify({hello: 'world'})).toMatchInlineSnapshot(` expect(linkify({hello: 'world'})).toMatchInlineSnapshot(`
"{ "{
\\"hello\\": \\"world\\" "hello": "world"
}" }"
`); `);
expect(linkify('hi there!')).toMatchInlineSnapshot(`"hi there!"`); expect(linkify('hi there!')).toMatchInlineSnapshot(`"hi there!"`);
@@ -142,13 +142,13 @@ test('jsonify formatter', () => {
expect(jsonify({hello: 'world'})).toMatchInlineSnapshot(` expect(jsonify({hello: 'world'})).toMatchInlineSnapshot(`
"{ "{
\\"hello\\": \\"world\\" "hello": "world"
}" }"
`); `);
expect(jsonify([{hello: 'world'}])).toMatchInlineSnapshot(` expect(jsonify([{hello: 'world'}])).toMatchInlineSnapshot(`
"[ "[
{ {
\\"hello\\": \\"world\\" "hello": "world"
} }
]" ]"
`); `);
@@ -181,7 +181,7 @@ test("jsonify doesn't process react elements", () => {
expect(jsonify('{ a: 1 }')).toMatchInlineSnapshot(`"{ a: 1 }"`); expect(jsonify('{ a: 1 }')).toMatchInlineSnapshot(`"{ a: 1 }"`);
expect(jsonify({a: 1})).toMatchInlineSnapshot(` expect(jsonify({a: 1})).toMatchInlineSnapshot(`
"{ "{
\\"a\\": 1 "a": 1
}" }"
`); `);
expect(jsonify(<span>hi</span>)).toMatchInlineSnapshot(` expect(jsonify(<span>hi</span>)).toMatchInlineSnapshot(`
@@ -197,7 +197,7 @@ test('truncate formatter', () => {
expect(truncate({test: true})).toMatchInlineSnapshot(` expect(truncate({test: true})).toMatchInlineSnapshot(`
"{ "{
\\"test\\": true "test": true
}" }"
`); `);
expect(truncate('abcde')).toEqual('abcde'); expect(truncate('abcde')).toEqual('abcde');

View File

@@ -1,14 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`handles single point 1`] = ` exports[`handles single point 1`] = `
Array [ [
Object { {
"color": "var(--flipper-background-default)", "color": "var(--flipper-background-default)",
"isCut": false, "isCut": false,
"markerKeys": Array [ "markerKeys": [
"1", "1",
], ],
"markerNames": Array [ "markerNames": [
"single point", "single point",
], ],
"positionY": 0, "positionY": 0,
@@ -17,4 +17,4 @@ Array [
] ]
`; `;
exports[`no points 1`] = `Array []`; exports[`no points 1`] = `[]`;

View File

@@ -66,7 +66,7 @@ test('it can store values', async () => {
expect((await res.findByTestId('value')).textContent).toEqual('2'); expect((await res.findByTestId('value')).textContent).toEqual('2');
expect(storage).toMatchInlineSnapshot(` expect(storage).toMatchInlineSnapshot(`
Object { {
"[useLocalStorage][Flipper]x": "2", "[useLocalStorage][Flipper]x": "2",
} }
`); `);
@@ -83,7 +83,7 @@ test('it can read default from storage', async () => {
expect((await res.findByTestId('value')).textContent).toEqual('4'); expect((await res.findByTestId('value')).textContent).toEqual('4');
expect(storage).toMatchInlineSnapshot(` expect(storage).toMatchInlineSnapshot(`
Object { {
"[useLocalStorage][Flipper]x": "4", "[useLocalStorage][Flipper]x": "4",
} }
`); `);

View File

@@ -26,7 +26,7 @@ test('createTablePlugin returns FlipperPlugin', () => {
const tablePlugin = createTablePlugin(PROPS); const tablePlugin = createTablePlugin(PROPS);
const p = startPlugin(tablePlugin); const p = startPlugin(tablePlugin);
expect(Object.keys(p.instance)).toMatchInlineSnapshot(` expect(Object.keys(p.instance)).toMatchInlineSnapshot(`
Array [ [
"selection", "selection",
"rows", "rows",
"isPaused", "isPaused",

View File

@@ -182,6 +182,8 @@ async function start() {
tcp: argv.tcp, tcp: argv.tcp,
}); });
// maybe at this point we could open up, http server is running.
const flipperServer = await startFlipperServer( const flipperServer = await startFlipperServer(
rootPath, rootPath,
staticPath, staticPath,

View File

@@ -53,6 +53,7 @@
"devDependencies": { "devDependencies": {
"@testing-library/dom": "^8.20.0", "@testing-library/dom": "^8.20.0",
"@types/deep-equal": "^1.0.1", "@types/deep-equal": "^1.0.1",
"@types/jest": "^29.5.1",
"@types/lodash.memoize": "^4.1.7", "@types/lodash.memoize": "^4.1.7",
"@types/react": "^17.0.39", "@types/react": "^17.0.39",
"@types/react-dom": "^17.0.12", "@types/react-dom": "^17.0.12",

View File

@@ -1,11 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`can create a Fake flipper with legacy wrapper 1`] = ` exports[`can create a Fake flipper with legacy wrapper 1`] = `
Object { {
"clients": Map { "clients": Map {
"TestApp#Android#MockAndroidDevice#serial" => Object { "TestApp#Android#MockAndroidDevice#serial" => {
"id": "TestApp#Android#MockAndroidDevice#serial", "id": "TestApp#Android#MockAndroidDevice#serial",
"query": Object { "query": {
"app": "TestApp", "app": "TestApp",
"device": "MockAndroidDevice", "device": "MockAndroidDevice",
"device_id": "serial", "device_id": "serial",
@@ -15,8 +15,8 @@ Object {
}, },
}, },
"deepLinkPayload": null, "deepLinkPayload": null,
"devices": Array [ "devices": [
Object { {
"deviceType": "physical", "deviceType": "physical",
"os": "Android", "os": "Android",
"serial": "serial", "serial": "serial",
@@ -30,15 +30,15 @@ Object {
"Hermesdebuggerrn", "Hermesdebuggerrn",
"React", "React",
}, },
"enabledPlugins": Object { "enabledPlugins": {
"TestApp": Array [ "TestApp": [
"TestPlugin", "TestPlugin",
], ],
}, },
"pluginMenuEntries": Array [], "pluginMenuEntries": [],
"selectedAppId": "TestApp#Android#MockAndroidDevice#serial", "selectedAppId": "TestApp#Android#MockAndroidDevice#serial",
"selectedAppPluginListRevision": 0, "selectedAppPluginListRevision": 0,
"selectedDevice": Object { "selectedDevice": {
"deviceType": "physical", "deviceType": "physical",
"os": "Android", "os": "Android",
"serial": "serial", "serial": "serial",
@@ -46,7 +46,7 @@ Object {
}, },
"selectedPlugin": "TestPlugin", "selectedPlugin": "TestPlugin",
"staticView": null, "staticView": null,
"uninitializedClients": Array [], "uninitializedClients": [],
"userPreferredApp": "TestApp", "userPreferredApp": "TestApp",
"userPreferredDevice": "MockAndroidDevice", "userPreferredDevice": "MockAndroidDevice",
"userPreferredPlugin": "TestPlugin", "userPreferredPlugin": "TestPlugin",
@@ -54,11 +54,11 @@ Object {
`; `;
exports[`can create a Fake flipper with legacy wrapper 2`] = ` exports[`can create a Fake flipper with legacy wrapper 2`] = `
Object { {
"clientPlugins": Map { "clientPlugins": Map {
"TestPlugin" => SandyPluginDefinition { "TestPlugin" => SandyPluginDefinition {
"css": undefined, "css": undefined,
"details": Object { "details": {
"dir": "/Users/mock/.flipper/thirdparty/flipper-plugin-sample1", "dir": "/Users/mock/.flipper/thirdparty/flipper-plugin-sample1",
"entry": "./test/index.js", "entry": "./test/index.js",
"id": "TestPlugin", "id": "TestPlugin",
@@ -73,21 +73,21 @@ Object {
}, },
"id": "TestPlugin", "id": "TestPlugin",
"isDevicePlugin": false, "isDevicePlugin": false,
"module": Object { "module": {
"Component": [Function], "Component": [Function],
"plugin": [Function], "plugin": [Function],
}, },
}, },
}, },
"devicePlugins": Map {}, "devicePlugins": Map {},
"disabledPlugins": Array [], "disabledPlugins": [],
"failedPlugins": Array [], "failedPlugins": [],
"gatekeepedPlugins": Array [], "gatekeepedPlugins": [],
"initialized": true, "initialized": true,
"installedPlugins": Map {}, "installedPlugins": Map {},
"loadedPlugins": Map {}, "loadedPlugins": Map {},
"marketplacePlugins": Array [], "marketplacePlugins": [],
"selectedPlugins": Array [], "selectedPlugins": [],
"uninstalledPluginNames": Set {}, "uninstalledPluginNames": Set {},
} }
`; `;

View File

@@ -64,5 +64,5 @@ test('can create a Fake flipper with legacy wrapper', async () => {
await getAllClients(state.connections)[0] await getAllClients(state.connections)[0]
.sandyPluginStates.get(TestPlugin.id)! .sandyPluginStates.get(TestPlugin.id)!
.exportState(testIdler, testOnStatusMessage), .exportState(testIdler, testOnStatusMessage),
).toMatchInlineSnapshot(`"{\\"count\\":1}"`); ).toMatchInlineSnapshot(`"{"count":1}"`);
}); });

View File

@@ -54,8 +54,8 @@ describe('ChangelogSheet', () => {
test('with last header, should not show changes', () => { test('with last header, should not show changes', () => {
markChangelogRead(storage, changelog); markChangelogRead(storage, changelog);
expect(storage.data).toMatchInlineSnapshot(` expect(storage.data).toMatchInlineSnapshot(`
Object { {
"FlipperChangelogStatus": "{\\"lastHeader\\":\\"# Version 2.0\\"}", "FlipperChangelogStatus": "{"lastHeader":"# Version 2.0"}",
} }
`); `);
expect(hasNewChangesToShow(storage, changelog)).toBe(false); expect(hasNewChangesToShow(storage, changelog)).toBe(false);
@@ -84,8 +84,8 @@ ${changelog}
`); `);
markChangelogRead(storage, newChangelog); markChangelogRead(storage, newChangelog);
expect(storage.data).toMatchInlineSnapshot(` expect(storage.data).toMatchInlineSnapshot(`
Object { {
"FlipperChangelogStatus": "{\\"lastHeader\\":\\"# Version 3.0\\"}", "FlipperChangelogStatus": "{"lastHeader":"# Version 3.0"}",
} }
`); `);
expect(hasNewChangesToShow(storage, newChangelog)).toBe(false); expect(hasNewChangesToShow(storage, newChangelog)).toBe(false);

View File

@@ -4,7 +4,7 @@ exports[`ShareSheetPendingDialog is rendered with status update 1`] = `
<div <div
className="css-gzchr8-Container e1k65efv0" className="css-gzchr8-Container e1k65efv0"
style={ style={
Object { {
"textAlign": "center", "textAlign": "center",
"width": undefined, "width": undefined,
} }
@@ -18,7 +18,7 @@ exports[`ShareSheetPendingDialog is rendered with status update 1`] = `
className="anticon anticon-loading anticon-spin ant-spin-dot" className="anticon anticon-loading anticon-spin ant-spin-dot"
role="img" role="img"
style={ style={
Object { {
"fontSize": 30, "fontSize": 30,
} }
} }
@@ -42,7 +42,7 @@ exports[`ShareSheetPendingDialog is rendered with status update 1`] = `
className="ant-typography" className="ant-typography"
onClick={null} onClick={null}
style={ style={
Object { {
"WebkitLineClamp": undefined, "WebkitLineClamp": undefined,
} }
} }
@@ -72,7 +72,7 @@ exports[`ShareSheetPendingDialog is rendered without status update 1`] = `
<div <div
className="css-gzchr8-Container e1k65efv0" className="css-gzchr8-Container e1k65efv0"
style={ style={
Object { {
"textAlign": "center", "textAlign": "center",
"width": undefined, "width": undefined,
} }
@@ -86,7 +86,7 @@ exports[`ShareSheetPendingDialog is rendered without status update 1`] = `
className="anticon anticon-loading anticon-spin ant-spin-dot" className="anticon anticon-loading anticon-spin ant-spin-dot"
role="img" role="img"
style={ style={
Object { {
"fontSize": 30, "fontSize": 30,
} }
} }
@@ -110,7 +110,7 @@ exports[`ShareSheetPendingDialog is rendered without status update 1`] = `
className="ant-typography" className="ant-typography"
onClick={null} onClick={null}
style={ style={
Object { {
"WebkitLineClamp": undefined, "WebkitLineClamp": undefined,
} }
} }

View File

@@ -58,17 +58,17 @@ test('It can store rows', () => {
expect(getFlipperDebugMessages().map(fixRowTimestamps)) expect(getFlipperDebugMessages().map(fixRowTimestamps))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
Array [ [
Object { {
"app": "Flipper", "app": "Flipper",
"direction": "toFlipper:message", "direction": "toFlipper:message",
"time": 1899-12-31T00:00:00.000Z, "time": 1899-12-31T00:00:00.000Z,
}, },
Object { {
"app": "FB4A", "app": "FB4A",
"device": "Android Phone", "device": "Android Phone",
"direction": "toClient:call", "direction": "toClient:call",
"payload": Object { "payload": {
"hello": "world", "hello": "world",
}, },
"time": 1899-12-31T00:00:00.000Z, "time": 1899-12-31T00:00:00.000Z,

View File

@@ -14,7 +14,6 @@ import {
uninstallPlugin, uninstallPlugin,
} from '../../reducers/pluginManager'; } from '../../reducers/pluginManager';
import {requirePlugin} from '../plugins'; import {requirePlugin} from '../plugins';
import {mocked} from 'ts-jest/utils';
import {TestUtils} from 'flipper-plugin'; import {TestUtils} from 'flipper-plugin';
import * as TestPlugin from '../../__tests__/test-utils/TestPlugin'; import * as TestPlugin from '../../__tests__/test-utils/TestPlugin';
import {_SandyPluginDefinition as SandyPluginDefinition} from 'flipper-plugin'; import {_SandyPluginDefinition as SandyPluginDefinition} from 'flipper-plugin';
@@ -63,7 +62,7 @@ const devicePluginDefinition = new SandyPluginDefinition(devicePluginDetails, {
}, },
}); });
const mockedRequirePlugin = mocked(requirePlugin); const mockedRequirePlugin = jest.mocked(requirePlugin);
let mockFlipper: MockFlipper; let mockFlipper: MockFlipper;
let mockClient: Client; let mockClient: Client;

View File

@@ -1,19 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`acknowledgeProblems 1`] = ` exports[`acknowledgeProblems 1`] = `
Object { {
"acknowledgedProblems": Array [ "acknowledgedProblems": [
"ios.sdk", "ios.sdk",
"common.openssl", "common.openssl",
], ],
"healthcheckReport": Object { "healthcheckReport": {
"categories": Object { "categories": {
"android": Object { "android": {
"checks": Object { "checks": {
"android.sdk": Object { "android.sdk": {
"key": "android.sdk", "key": "android.sdk",
"label": "SDK Installed", "label": "SDK Installed",
"result": Object { "result": {
"isAcknowledged": true, "isAcknowledged": true,
"status": "SUCCESS", "status": "SUCCESS",
}, },
@@ -21,17 +21,17 @@ Object {
}, },
"key": "android", "key": "android",
"label": "Android", "label": "Android",
"result": Object { "result": {
"isAcknowledged": true, "isAcknowledged": true,
"status": "SUCCESS", "status": "SUCCESS",
}, },
}, },
"common": Object { "common": {
"checks": Object { "checks": {
"common.openssl": Object { "common.openssl": {
"key": "common.openssl", "key": "common.openssl",
"label": "OpenSSL Istalled", "label": "OpenSSL Istalled",
"result": Object { "result": {
"isAcknowledged": true, "isAcknowledged": true,
"status": "FAILED", "status": "FAILED",
}, },
@@ -39,17 +39,17 @@ Object {
}, },
"key": "common", "key": "common",
"label": "Common", "label": "Common",
"result": Object { "result": {
"isAcknowledged": true, "isAcknowledged": true,
"status": "FAILED", "status": "FAILED",
}, },
}, },
"ios": Object { "ios": {
"checks": Object { "checks": {
"ios.sdk": Object { "ios.sdk": {
"key": "ios.sdk", "key": "ios.sdk",
"label": "SDK Installed", "label": "SDK Installed",
"result": Object { "result": {
"isAcknowledged": true, "isAcknowledged": true,
"status": "FAILED", "status": "FAILED",
}, },
@@ -57,13 +57,13 @@ Object {
}, },
"key": "ios", "key": "ios",
"label": "iOS", "label": "iOS",
"result": Object { "result": {
"isAcknowledged": true, "isAcknowledged": true,
"status": "FAILED", "status": "FAILED",
}, },
}, },
}, },
"result": Object { "result": {
"isAcknowledged": true, "isAcknowledged": true,
"status": "FAILED", "status": "FAILED",
}, },
@@ -72,16 +72,16 @@ Object {
`; `;
exports[`finish 1`] = ` exports[`finish 1`] = `
Object { {
"acknowledgedProblems": Array [], "acknowledgedProblems": [],
"healthcheckReport": Object { "healthcheckReport": {
"categories": Object { "categories": {
"android": Object { "android": {
"checks": Object { "checks": {
"android.sdk": Object { "android.sdk": {
"key": "android.sdk", "key": "android.sdk",
"label": "SDK Installed", "label": "SDK Installed",
"result": Object { "result": {
"isAcknowledged": false, "isAcknowledged": false,
"message": "Updated Test Message", "message": "Updated Test Message",
"status": "SUCCESS", "status": "SUCCESS",
@@ -90,17 +90,17 @@ Object {
}, },
"key": "android", "key": "android",
"label": "Android", "label": "Android",
"result": Object { "result": {
"isAcknowledged": false, "isAcknowledged": false,
"status": "SUCCESS", "status": "SUCCESS",
}, },
}, },
"common": Object { "common": {
"checks": Object { "checks": {
"common.openssl": Object { "common.openssl": {
"key": "common.openssl", "key": "common.openssl",
"label": "OpenSSL Istalled", "label": "OpenSSL Istalled",
"result": Object { "result": {
"isAcknowledged": false, "isAcknowledged": false,
"message": "Updated Test Message", "message": "Updated Test Message",
"status": "SUCCESS", "status": "SUCCESS",
@@ -109,17 +109,17 @@ Object {
}, },
"key": "common", "key": "common",
"label": "Common", "label": "Common",
"result": Object { "result": {
"isAcknowledged": false, "isAcknowledged": false,
"status": "SUCCESS", "status": "SUCCESS",
}, },
}, },
"ios": Object { "ios": {
"checks": Object { "checks": {
"ios.sdk": Object { "ios.sdk": {
"key": "ios.sdk", "key": "ios.sdk",
"label": "SDK Installed", "label": "SDK Installed",
"result": Object { "result": {
"isAcknowledged": false, "isAcknowledged": false,
"message": "Updated Test Message", "message": "Updated Test Message",
"status": "SUCCESS", "status": "SUCCESS",
@@ -128,13 +128,13 @@ Object {
}, },
"key": "ios", "key": "ios",
"label": "iOS", "label": "iOS",
"result": Object { "result": {
"isAcknowledged": false, "isAcknowledged": false,
"status": "SUCCESS", "status": "SUCCESS",
}, },
}, },
}, },
"result": Object { "result": {
"status": "SUCCESS", "status": "SUCCESS",
}, },
}, },
@@ -142,60 +142,60 @@ Object {
`; `;
exports[`startHealthCheck 1`] = ` exports[`startHealthCheck 1`] = `
Object { {
"acknowledgedProblems": Array [], "acknowledgedProblems": [],
"healthcheckReport": Object { "healthcheckReport": {
"categories": Object { "categories": {
"android": Object { "android": {
"checks": Object { "checks": {
"android.sdk": Object { "android.sdk": {
"key": "android.sdk", "key": "android.sdk",
"label": "SDK Installed", "label": "SDK Installed",
"result": Object { "result": {
"status": "IN_PROGRESS", "status": "IN_PROGRESS",
}, },
}, },
}, },
"key": "android", "key": "android",
"label": "Android", "label": "Android",
"result": Object { "result": {
"status": "IN_PROGRESS", "status": "IN_PROGRESS",
}, },
}, },
"common": Object { "common": {
"checks": Object { "checks": {
"common.openssl": Object { "common.openssl": {
"key": "common.openssl", "key": "common.openssl",
"label": "OpenSSL Istalled", "label": "OpenSSL Istalled",
"result": Object { "result": {
"status": "IN_PROGRESS", "status": "IN_PROGRESS",
}, },
}, },
}, },
"key": "common", "key": "common",
"label": "Common", "label": "Common",
"result": Object { "result": {
"status": "IN_PROGRESS", "status": "IN_PROGRESS",
}, },
}, },
"ios": Object { "ios": {
"checks": Object { "checks": {
"ios.sdk": Object { "ios.sdk": {
"key": "ios.sdk", "key": "ios.sdk",
"label": "SDK Installed", "label": "SDK Installed",
"result": Object { "result": {
"status": "IN_PROGRESS", "status": "IN_PROGRESS",
}, },
}, },
}, },
"key": "ios", "key": "ios",
"label": "iOS", "label": "iOS",
"result": Object { "result": {
"status": "IN_PROGRESS", "status": "IN_PROGRESS",
}, },
}, },
}, },
"result": Object { "result": {
"status": "IN_PROGRESS", "status": "IN_PROGRESS",
}, },
}, },
@@ -203,16 +203,16 @@ Object {
`; `;
exports[`statuses updated after healthchecks finished 1`] = ` exports[`statuses updated after healthchecks finished 1`] = `
Object { {
"acknowledgedProblems": Array [], "acknowledgedProblems": [],
"healthcheckReport": Object { "healthcheckReport": {
"categories": Object { "categories": {
"android": Object { "android": {
"checks": Object { "checks": {
"android.sdk": Object { "android.sdk": {
"key": "android.sdk", "key": "android.sdk",
"label": "SDK Installed", "label": "SDK Installed",
"result": Object { "result": {
"isAcknowledged": false, "isAcknowledged": false,
"message": "Updated Test Message", "message": "Updated Test Message",
"status": "FAILED", "status": "FAILED",
@@ -221,17 +221,17 @@ Object {
}, },
"key": "android", "key": "android",
"label": "Android", "label": "Android",
"result": Object { "result": {
"isAcknowledged": false, "isAcknowledged": false,
"status": "FAILED", "status": "FAILED",
}, },
}, },
"common": Object { "common": {
"checks": Object { "checks": {
"common.openssl": Object { "common.openssl": {
"key": "common.openssl", "key": "common.openssl",
"label": "OpenSSL Istalled", "label": "OpenSSL Istalled",
"result": Object { "result": {
"isAcknowledged": false, "isAcknowledged": false,
"message": "Updated Test Message", "message": "Updated Test Message",
"status": "SUCCESS", "status": "SUCCESS",
@@ -240,16 +240,16 @@ Object {
}, },
"key": "common", "key": "common",
"label": "Common", "label": "Common",
"result": Object { "result": {
"status": "SUCCESS", "status": "SUCCESS",
}, },
}, },
"ios": Object { "ios": {
"checks": Object { "checks": {
"ios.sdk": Object { "ios.sdk": {
"key": "ios.sdk", "key": "ios.sdk",
"label": "SDK Installed", "label": "SDK Installed",
"result": Object { "result": {
"isAcknowledged": false, "isAcknowledged": false,
"message": "Updated Test Message", "message": "Updated Test Message",
"status": "SUCCESS", "status": "SUCCESS",
@@ -258,12 +258,12 @@ Object {
}, },
"key": "ios", "key": "ios",
"label": "iOS", "label": "iOS",
"result": Object { "result": {
"status": "SUCCESS", "status": "SUCCESS",
}, },
}, },
}, },
"result": Object { "result": {
"isAcknowledged": false, "isAcknowledged": false,
"status": "FAILED", "status": "FAILED",
}, },
@@ -272,16 +272,16 @@ Object {
`; `;
exports[`updateHealthcheckResult 1`] = ` exports[`updateHealthcheckResult 1`] = `
Object { {
"acknowledgedProblems": Array [], "acknowledgedProblems": [],
"healthcheckReport": Object { "healthcheckReport": {
"categories": Object { "categories": {
"android": Object { "android": {
"checks": Object { "checks": {
"android.sdk": Object { "android.sdk": {
"key": "android.sdk", "key": "android.sdk",
"label": "SDK Installed", "label": "SDK Installed",
"result": Object { "result": {
"isAcknowledged": false, "isAcknowledged": false,
"message": "Updated Test Message", "message": "Updated Test Message",
"status": "SUCCESS", "status": "SUCCESS",
@@ -290,44 +290,44 @@ Object {
}, },
"key": "android", "key": "android",
"label": "Android", "label": "Android",
"result": Object { "result": {
"status": "IN_PROGRESS", "status": "IN_PROGRESS",
}, },
}, },
"common": Object { "common": {
"checks": Object { "checks": {
"common.openssl": Object { "common.openssl": {
"key": "common.openssl", "key": "common.openssl",
"label": "OpenSSL Istalled", "label": "OpenSSL Istalled",
"result": Object { "result": {
"status": "IN_PROGRESS", "status": "IN_PROGRESS",
}, },
}, },
}, },
"key": "common", "key": "common",
"label": "Common", "label": "Common",
"result": Object { "result": {
"status": "IN_PROGRESS", "status": "IN_PROGRESS",
}, },
}, },
"ios": Object { "ios": {
"checks": Object { "checks": {
"ios.sdk": Object { "ios.sdk": {
"key": "ios.sdk", "key": "ios.sdk",
"label": "SDK Installed", "label": "SDK Installed",
"result": Object { "result": {
"status": "IN_PROGRESS", "status": "IN_PROGRESS",
}, },
}, },
}, },
"key": "ios", "key": "ios",
"label": "iOS", "label": "iOS",
"result": Object { "result": {
"status": "IN_PROGRESS", "status": "IN_PROGRESS",
}, },
}, },
}, },
"result": Object { "result": {
"status": "IN_PROGRESS", "status": "IN_PROGRESS",
}, },
}, },

View File

@@ -134,7 +134,7 @@ test('can handle plugins that throw at start', async () => {
expect(client.connected.get()).toBe(true); expect(client.connected.get()).toBe(true);
expect((console.error as any).mock.calls[0]).toMatchInlineSnapshot(` expect((console.error as any).mock.calls[0]).toMatchInlineSnapshot(`
Array [ [
"Failed to start plugin 'TestPlugin': ", "Failed to start plugin 'TestPlugin': ",
[Error: Broken plugin], [Error: Broken plugin],
] ]
@@ -144,7 +144,7 @@ test('can handle plugins that throw at start', async () => {
const client2 = await createClient(device2, client.query.app); const client2 = await createClient(device2, client.query.app);
expect((console.error as any).mock.calls[1]).toMatchInlineSnapshot(` expect((console.error as any).mock.calls[1]).toMatchInlineSnapshot(`
Array [ [
"Failed to start plugin 'TestPlugin': ", "Failed to start plugin 'TestPlugin': ",
[Error: Broken plugin], [Error: Broken plugin],
] ]
@@ -172,7 +172,7 @@ test('can handle device plugins that throw at start', async () => {
); );
expect(mockedConsole.errorCalls[0]).toMatchInlineSnapshot(` expect(mockedConsole.errorCalls[0]).toMatchInlineSnapshot(`
Array [ [
"Failed to start device plugin 'TestPlugin': ", "Failed to start device plugin 'TestPlugin': ",
[Error: Broken device plugin], [Error: Broken device plugin],
] ]
@@ -188,7 +188,7 @@ test('can handle device plugins that throw at start', async () => {
expect(store.getState().connections.devices.length).toBe(2); expect(store.getState().connections.devices.length).toBe(2);
expect(device2.connected.get()).toBe(true); expect(device2.connected.get()).toBe(true);
expect(mockedConsole.errorCalls[1]).toMatchInlineSnapshot(` expect(mockedConsole.errorCalls[1]).toMatchInlineSnapshot(`
Array [ [
"Failed to start device plugin 'TestPlugin': ", "Failed to start device plugin 'TestPlugin': ",
[Error: Broken device plugin], [Error: Broken device plugin],
] ]

View File

@@ -142,11 +142,11 @@ test('addNotification removes duplicates', () => {
}), }),
); );
expect(res).toMatchInlineSnapshot(` expect(res).toMatchInlineSnapshot(`
Object { {
"activeNotifications": Array [ "activeNotifications": [
Object { {
"client": null, "client": null,
"notification": Object { "notification": {
"id": "otherId", "id": "otherId",
"message": "message", "message": "message",
"severity": "warning", "severity": "warning",
@@ -155,10 +155,10 @@ test('addNotification removes duplicates', () => {
"pluginId": "test", "pluginId": "test",
}, },
], ],
"blocklistedCategories": Array [], "blocklistedCategories": [],
"blocklistedPlugins": Array [], "blocklistedPlugins": [],
"clearedNotifications": Set {}, "clearedNotifications": Set {},
"invalidatedNotifications": Array [], "invalidatedNotifications": [],
} }
`); `);
}); });
@@ -195,11 +195,11 @@ test('reduce removeNotification', () => {
}), }),
); );
expect(res).toMatchInlineSnapshot(` expect(res).toMatchInlineSnapshot(`
Object { {
"activeNotifications": Array [ "activeNotifications": [
Object { {
"client": null, "client": null,
"notification": Object { "notification": {
"id": "otherId", "id": "otherId",
"message": "message", "message": "message",
"severity": "warning", "severity": "warning",
@@ -207,9 +207,9 @@ test('reduce removeNotification', () => {
}, },
"pluginId": "test", "pluginId": "test",
}, },
Object { {
"client": null, "client": null,
"notification": Object { "notification": {
"id": "id", "id": "id",
"message": "slightly different message", "message": "slightly different message",
"severity": "warning", "severity": "warning",
@@ -218,10 +218,10 @@ test('reduce removeNotification', () => {
"pluginId": "test", "pluginId": "test",
}, },
], ],
"blocklistedCategories": Array [], "blocklistedCategories": [],
"blocklistedPlugins": Array [], "blocklistedPlugins": [],
"clearedNotifications": Set {}, "clearedNotifications": Set {},
"invalidatedNotifications": Array [], "invalidatedNotifications": [],
} }
`); `);
}); });
@@ -248,11 +248,11 @@ test('notifications from plugins arrive in the notifications reducer', async ()
sendMessage('testMessage', {}); sendMessage('testMessage', {});
client.flushMessageBuffer(); client.flushMessageBuffer();
expect(store.getState().notifications).toMatchInlineSnapshot(` expect(store.getState().notifications).toMatchInlineSnapshot(`
Object { {
"activeNotifications": Array [ "activeNotifications": [
Object { {
"client": "TestApp#Android#MockAndroidDevice#serial", "client": "TestApp#Android#MockAndroidDevice#serial",
"notification": Object { "notification": {
"action": "dosomething", "action": "dosomething",
"id": "test", "id": "test",
"message": "test message", "message": "test message",
@@ -262,10 +262,10 @@ test('notifications from plugins arrive in the notifications reducer', async ()
"pluginId": "TestPlugin", "pluginId": "TestPlugin",
}, },
], ],
"blocklistedCategories": Array [], "blocklistedCategories": [],
"blocklistedPlugins": Array [], "blocklistedPlugins": [],
"clearedNotifications": Set {}, "clearedNotifications": Set {},
"invalidatedNotifications": Array [], "invalidatedNotifications": [],
} }
`); `);
}); });
@@ -290,11 +290,11 @@ test('notifications from a device plugin arrive in the notifications reducer', a
const {store} = await createMockFlipperWithPlugin(TestPlugin); const {store} = await createMockFlipperWithPlugin(TestPlugin);
trigger(); trigger();
expect(store.getState().notifications).toMatchInlineSnapshot(` expect(store.getState().notifications).toMatchInlineSnapshot(`
Object { {
"activeNotifications": Array [ "activeNotifications": [
Object { {
"client": "serial", "client": "serial",
"notification": Object { "notification": {
"action": "dosomething", "action": "dosomething",
"id": "test", "id": "test",
"message": "test message", "message": "test message",
@@ -304,10 +304,10 @@ test('notifications from a device plugin arrive in the notifications reducer', a
"pluginId": "TestPlugin", "pluginId": "TestPlugin",
}, },
], ],
"blocklistedCategories": Array [], "blocklistedCategories": [],
"blocklistedPlugins": Array [], "blocklistedPlugins": [],
"clearedNotifications": Set {}, "clearedNotifications": Set {},
"invalidatedNotifications": Array [], "invalidatedNotifications": [],
} }
`); `);
}); });
@@ -334,25 +334,25 @@ test('errors end up as notifications if crash reporter is active', async () => {
sendError('gone wrong'); sendError('gone wrong');
client.flushMessageBuffer(); client.flushMessageBuffer();
expect(store.getState().notifications).toMatchInlineSnapshot(` expect(store.getState().notifications).toMatchInlineSnapshot(`
Object { {
"activeNotifications": Array [ "activeNotifications": [
Object { {
"client": "serial", "client": "serial",
"notification": Object { "notification": {
"action": "0", "action": "0",
"category": "\\"gone wrong\\"", "category": ""gone wrong"",
"id": "0", "id": "0",
"message": "Callstack: No callstack available", "message": "Callstack: No callstack available",
"severity": "error", "severity": "error",
"title": "CRASH: Plugin ErrorReason: \\"gone wrong\\"", "title": "CRASH: Plugin ErrorReason: "gone wrong"",
}, },
"pluginId": "CrashReporter", "pluginId": "CrashReporter",
}, },
], ],
"blocklistedCategories": Array [], "blocklistedCategories": [],
"blocklistedPlugins": Array [], "blocklistedPlugins": [],
"clearedNotifications": Set {}, "clearedNotifications": Set {},
"invalidatedNotifications": Array [], "invalidatedNotifications": [],
} }
`); `);
}); });
@@ -386,12 +386,12 @@ test('errors end NOT up as notifications if crash reporter is active but suppres
sendError('gone wrong'); sendError('gone wrong');
client.flushMessageBuffer(); client.flushMessageBuffer();
expect(store.getState().notifications).toMatchInlineSnapshot(` expect(store.getState().notifications).toMatchInlineSnapshot(`
Object { {
"activeNotifications": Array [], "activeNotifications": [],
"blocklistedCategories": Array [], "blocklistedCategories": [],
"blocklistedPlugins": Array [], "blocklistedPlugins": [],
"clearedNotifications": Set {}, "clearedNotifications": Set {},
"invalidatedNotifications": Array [], "invalidatedNotifications": [],
} }
`); `);
}); });

View File

@@ -230,10 +230,10 @@ test('it can send messages from sandy clients', async () => {
client.initPlugin(TestPlugin.id); client.initPlugin(TestPlugin.id);
await pluginInstance.send('test', {test: 3}); await pluginInstance.send('test', {test: 3});
expect(testMethodCalledWith).toMatchInlineSnapshot(` expect(testMethodCalledWith).toMatchInlineSnapshot(`
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "test", "method": "test",
"params": Object { "params": {
"test": 3, "test": 3,
}, },
} }

View File

@@ -125,7 +125,7 @@ test('Can render and launch android apps', async () => {
await sleep(1); // give exec time to resolve await sleep(1); // give exec time to resolve
expect(await renderer.findAllByText(/emulator/)).toMatchInlineSnapshot(` expect(await renderer.findAllByText(/emulator/)).toMatchInlineSnapshot(`
Array [ [
<span> <span>
emulator1 emulator1
</span>, </span>,
@@ -140,11 +140,11 @@ test('Can render and launch android apps', async () => {
await sleep(1000); await sleep(1000);
expect(onClose).toBeCalled(); expect(onClose).toBeCalled();
expect(exec.mock.calls).toMatchInlineSnapshot(` expect(exec.mock.calls).toMatchInlineSnapshot(`
Array [ [
Array [ [
"android-get-emulators", "android-get-emulators",
], ],
Array [ [
"android-launch-emulator", "android-launch-emulator",
"emulator2", "emulator2",
false, false,

View File

@@ -1230,9 +1230,9 @@ test('Non sandy plugins are exported properly if they are still queued', async (
const serial = storeExport.exportStoreData.device!.serial; const serial = storeExport.exportStoreData.device!.serial;
expect(serial).not.toBeFalsy(); expect(serial).not.toBeFalsy();
expect(storeExport.exportStoreData.pluginStates2).toMatchInlineSnapshot(` expect(storeExport.exportStoreData.pluginStates2).toMatchInlineSnapshot(`
Object { {
"TestApp#Android#MockAndroidDevice#00000000-0000-0000-0000-000000000000-serial": Object { "TestApp#Android#MockAndroidDevice#00000000-0000-0000-0000-000000000000-serial": {
"TestPlugin": "{\\"counter\\":3}", "TestPlugin": "{"counter":3}",
}, },
} }
`); `);
@@ -1323,18 +1323,18 @@ test('Sandy plugins are imported properly', async () => {
expect(client.sandyPluginStates.get(TestPlugin.id)!.exportStateSync()) expect(client.sandyPluginStates.get(TestPlugin.id)!.exportStateSync())
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
Object { {
"counter": 0, "counter": 0,
"otherState": Object { "otherState": {
"testCount": 0, "testCount": 0,
}, },
} }
`); `);
expect(client2.sandyPluginStates.get(TestPlugin.id)!.exportStateSync()) expect(client2.sandyPluginStates.get(TestPlugin.id)!.exportStateSync())
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
Object { {
"counter": 3, "counter": 3,
"otherState": Object { "otherState": {
"testCount": -3, "testCount": -3,
}, },
} }
@@ -1428,9 +1428,9 @@ test('Sandy device plugins are exported / imported properly', async () => {
]) ])
)[sandyDeviceTestPlugin.id], )[sandyDeviceTestPlugin.id],
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Object { {
"counter": 0, "counter": 0,
"otherState": Object { "otherState": {
"testCount": 0, "testCount": 0,
}, },
} }
@@ -1440,10 +1440,10 @@ test('Sandy device plugins are exported / imported properly', async () => {
sandyDeviceTestPlugin.id, sandyDeviceTestPlugin.id,
]), ]),
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
Object { {
"TestPlugin": Object { "TestPlugin": {
"counter": 4, "counter": 4,
"otherState": Object { "otherState": {
"testCount": -3, "testCount": -3,
}, },
}, },
@@ -1661,7 +1661,7 @@ test('Sandy plugins with complex data are imported / exported correctly', async
`); `);
expect(api.s.get()).toMatchInlineSnapshot(` expect(api.s.get()).toMatchInlineSnapshot(`
Set { Set {
Object { {
"x": 2, "x": 2,
}, },
} }
@@ -1730,7 +1730,7 @@ test('Sandy device plugins with complex data are imported / exported correctly'
`); `);
expect(api.s.get()).toMatchInlineSnapshot(` expect(api.s.get()).toMatchInlineSnapshot(`
Set { Set {
Object { {
"x": 2, "x": 2,
}, },
} }

View File

@@ -79,7 +79,7 @@ describe('info', () => {
); );
const inspectorPluginSelectionInfo = getInfo(); const inspectorPluginSelectionInfo = getInfo();
expect(networkPluginSelectionInfo.selection).toMatchInlineSnapshot(` expect(networkPluginSelectionInfo.selection).toMatchInlineSnapshot(`
Object { {
"app": "TestApp", "app": "TestApp",
"archived": false, "archived": false,
"device": "MockAndroidDevice", "device": "MockAndroidDevice",
@@ -94,7 +94,7 @@ describe('info', () => {
} }
`); `);
expect(inspectorPluginSelectionInfo.selection).toMatchInlineSnapshot(` expect(inspectorPluginSelectionInfo.selection).toMatchInlineSnapshot(`
Object { {
"app": "TestApp", "app": "TestApp",
"archived": false, "archived": false,
"device": "MockAndroidDevice", "device": "MockAndroidDevice",

View File

@@ -118,13 +118,11 @@ test('queue - events are processed immediately if plugin is selected', async ()
sendMessage('noop', {}); sendMessage('noop', {});
client.flushMessageBuffer(); client.flushMessageBuffer();
expect(getTestPluginState(client)).toMatchInlineSnapshot(` expect(getTestPluginState(client)).toMatchInlineSnapshot(`
Object { {
"count": 5, "count": 5,
} }
`); `);
expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot( expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(`{}`);
`Object {}`,
);
}); });
test('queue - events are NOT processed immediately if plugin is NOT selected (but enabled)', async () => { test('queue - events are NOT processed immediately if plugin is NOT selected (but enabled)', async () => {
@@ -139,36 +137,36 @@ test('queue - events are NOT processed immediately if plugin is NOT selected (bu
expect(getTestPluginState(client).count).toBe(0); expect(getTestPluginState(client).count).toBe(0);
// the first message is already visible cause of the leading debounce // the first message is already visible cause of the leading debounce
expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(` expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(`
Object { {
"TestApp#Android#MockAndroidDevice#serial#TestPlugin": Array [ "TestApp#Android#MockAndroidDevice#serial#TestPlugin": [
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object {}, "params": {},
}, },
], ],
} }
`); `);
client.flushMessageBuffer(); client.flushMessageBuffer();
expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(` expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(`
Object { {
"TestApp#Android#MockAndroidDevice#serial#TestPlugin": Array [ "TestApp#Android#MockAndroidDevice#serial#TestPlugin": [
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object {}, "params": {},
}, },
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object { "params": {
"delta": 2, "delta": 2,
}, },
}, },
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object { "params": {
"delta": 3, "delta": 3,
}, },
}, },
@@ -204,7 +202,7 @@ test('queue - events are NOT processed immediately if plugin is NOT selected (bu
selectDeviceLogs(store); selectDeviceLogs(store);
sendMessage('inc', {delta: 4}); sendMessage('inc', {delta: 4});
client.flushMessageBuffer(); client.flushMessageBuffer();
expect(client.messageBuffer).toMatchInlineSnapshot(`Object {}`); expect(client.messageBuffer).toMatchInlineSnapshot(`{}`);
expect(store.getState().pluginMessageQueue).toEqual({}); expect(store.getState().pluginMessageQueue).toEqual({});
// star again, plugin still not selected, message is queued // star again, plugin still not selected, message is queued
@@ -243,8 +241,8 @@ test('queue - events ARE processed immediately if plugin is NOT selected / enabl
}), }),
); );
expect(store.getState().connections.enabledPlugins).toMatchInlineSnapshot(` expect(store.getState().connections.enabledPlugins).toMatchInlineSnapshot(`
Object { {
"TestApp": Array [], "TestApp": [],
} }
`); `);
@@ -258,9 +256,7 @@ test('queue - events ARE processed immediately if plugin is NOT selected / enabl
// the first message is already visible cause of the leading debounce // the first message is already visible cause of the leading debounce
expect(pluginState().count).toBe(1); expect(pluginState().count).toBe(1);
// message queue was never involved due to the bypass... // message queue was never involved due to the bypass...
expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot( expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(`{}`);
`Object {}`,
);
// flush will make the others visible // flush will make the others visible
client.flushMessageBuffer(); client.flushMessageBuffer();
expect(pluginState().count).toBe(6); expect(pluginState().count).toBe(6);
@@ -280,12 +276,12 @@ test('queue - events are queued for plugins that are favorite when app is not se
sendMessage('inc', {delta: 2}); sendMessage('inc', {delta: 2});
expect(getTestPluginState(client)).toEqual({count: 0}); expect(getTestPluginState(client)).toEqual({count: 0});
expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(` expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(`
Object { {
"TestApp#Android#MockAndroidDevice#serial#TestPlugin": Array [ "TestApp#Android#MockAndroidDevice#serial#TestPlugin": [
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object { "params": {
"delta": 2, "delta": 2,
}, },
}, },
@@ -313,21 +309,21 @@ test('queue - events are queued for plugins that are favorite when app is select
client2.flushMessageBuffer(); client2.flushMessageBuffer();
expect(getTestPluginState(client)).toEqual({count: 0}); expect(getTestPluginState(client)).toEqual({count: 0});
expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(` expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(`
Object { {
"TestApp#Android#MockAndroidDevice#serial#TestPlugin": Array [ "TestApp#Android#MockAndroidDevice#serial#TestPlugin": [
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object { "params": {
"delta": 2, "delta": 2,
}, },
}, },
], ],
"TestApp#Android#MockAndroidDevice#serial2#TestPlugin": Array [ "TestApp#Android#MockAndroidDevice#serial2#TestPlugin": [
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object { "params": {
"delta": 3, "delta": 3,
}, },
}, },
@@ -527,43 +523,43 @@ test('client - incoming messages are buffered and flushed together', async () =>
expect(getTestPluginState(client).count).toBe(0); expect(getTestPluginState(client).count).toBe(0);
// the first message is already visible cause of the leading debounce // the first message is already visible cause of the leading debounce
expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(` expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(`
Object { {
"TestApp#Android#MockAndroidDevice#serial#TestPlugin": Array [ "TestApp#Android#MockAndroidDevice#serial#TestPlugin": [
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object {}, "params": {},
}, },
], ],
} }
`); `);
expect(client.messageBuffer).toMatchInlineSnapshot(` expect(client.messageBuffer).toMatchInlineSnapshot(`
Object { {
"TestApp#Android#MockAndroidDevice#serial#StubPlugin": Object { "TestApp#Android#MockAndroidDevice#serial#StubPlugin": {
"messages": Array [ "messages": [
Object { {
"api": "StubPlugin", "api": "StubPlugin",
"method": "log", "method": "log",
"params": Object { "params": {
"line": "suff", "line": "suff",
}, },
}, },
], ],
"plugin": "[SandyPluginInstance]", "plugin": "[SandyPluginInstance]",
}, },
"TestApp#Android#MockAndroidDevice#serial#TestPlugin": Object { "TestApp#Android#MockAndroidDevice#serial#TestPlugin": {
"messages": Array [ "messages": [
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object { "params": {
"delta": 2, "delta": 2,
}, },
}, },
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object { "params": {
"delta": 3, "delta": 3,
}, },
}, },
@@ -578,42 +574,42 @@ test('client - incoming messages are buffered and flushed together', async () =>
await sleep(500); await sleep(500);
expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(` expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(`
Object { {
"TestApp#Android#MockAndroidDevice#serial#StubPlugin": Array [ "TestApp#Android#MockAndroidDevice#serial#StubPlugin": [
Object { {
"api": "StubPlugin", "api": "StubPlugin",
"method": "log", "method": "log",
"params": Object { "params": {
"line": "suff", "line": "suff",
}, },
}, },
], ],
"TestApp#Android#MockAndroidDevice#serial#TestPlugin": Array [ "TestApp#Android#MockAndroidDevice#serial#TestPlugin": [
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object {}, "params": {},
}, },
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object { "params": {
"delta": 2, "delta": 2,
}, },
}, },
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object { "params": {
"delta": 3, "delta": 3,
}, },
}, },
], ],
} }
`); `);
expect(client.messageBuffer).toMatchInlineSnapshot(`Object {}`); expect(client.messageBuffer).toMatchInlineSnapshot(`{}`);
expect(StubPlugin.persistedStateReducer.mock.calls).toMatchInlineSnapshot( expect(StubPlugin.persistedStateReducer.mock.calls).toMatchInlineSnapshot(
`Array []`, `[]`,
); );
// tigger processing the queue // tigger processing the queue
@@ -625,11 +621,11 @@ test('client - incoming messages are buffered and flushed together', async () =>
); );
expect(StubPlugin.persistedStateReducer.mock.calls).toMatchInlineSnapshot(` expect(StubPlugin.persistedStateReducer.mock.calls).toMatchInlineSnapshot(`
Array [ [
Array [ [
undefined, undefined,
"log", "log",
Object { {
"line": "suff", "line": "suff",
}, },
], ],
@@ -637,25 +633,25 @@ test('client - incoming messages are buffered and flushed together', async () =>
`); `);
expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(` expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(`
Object { {
"TestApp#Android#MockAndroidDevice#serial#StubPlugin": Array [], "TestApp#Android#MockAndroidDevice#serial#StubPlugin": [],
"TestApp#Android#MockAndroidDevice#serial#TestPlugin": Array [ "TestApp#Android#MockAndroidDevice#serial#TestPlugin": [
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object {}, "params": {},
}, },
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object { "params": {
"delta": 2, "delta": 2,
}, },
}, },
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object { "params": {
"delta": 3, "delta": 3,
}, },
}, },
@@ -673,13 +669,13 @@ test('queue - messages that have not yet flushed be lost when disabling the plug
sendMessage('inc', {delta: 2}); sendMessage('inc', {delta: 2});
expect(client.messageBuffer).toMatchInlineSnapshot(` expect(client.messageBuffer).toMatchInlineSnapshot(`
Object { {
"TestApp#Android#MockAndroidDevice#serial#TestPlugin": Object { "TestApp#Android#MockAndroidDevice#serial#TestPlugin": {
"messages": Array [ "messages": [
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object { "params": {
"delta": 2, "delta": 2,
}, },
}, },
@@ -689,12 +685,12 @@ test('queue - messages that have not yet flushed be lost when disabling the plug
} }
`); `);
expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(` expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(`
Object { {
"TestApp#Android#MockAndroidDevice#serial#TestPlugin": Array [ "TestApp#Android#MockAndroidDevice#serial#TestPlugin": [
Object { {
"api": "TestPlugin", "api": "TestPlugin",
"method": "inc", "method": "inc",
"params": Object {}, "params": {},
}, },
], ],
} }
@@ -702,10 +698,8 @@ test('queue - messages that have not yet flushed be lost when disabling the plug
// disable // disable
await switchTestPlugin(store, client); await switchTestPlugin(store, client);
expect(client.messageBuffer).toMatchInlineSnapshot(`Object {}`); expect(client.messageBuffer).toMatchInlineSnapshot(`{}`);
expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot( expect(store.getState().pluginMessageQueue).toMatchInlineSnapshot(`{}`);
`Object {}`,
);
// re-enable, no messages arrive // re-enable, no messages arrive
await switchTestPlugin(store, client); await switchTestPlugin(store, client);

View File

@@ -12,8 +12,6 @@ import {createStore, Store} from 'redux';
import produce from 'immer'; import produce from 'immer';
import {sleep} from 'flipper-plugin'; import {sleep} from 'flipper-plugin';
jest.useFakeTimers();
const initialState = { const initialState = {
counter: {count: 0}, counter: {count: 0},
somethingUnrelated: false, somethingUnrelated: false,
@@ -33,10 +31,12 @@ function reducer(state: State, action: Action): State {
}); });
} }
jest.useFakeTimers();
describe('sideeffect', () => { describe('sideeffect', () => {
let store: Store<State, Action>; let store: Store<State, Action>;
let events: string[]; let events: string[];
let unsubscribe: undefined | (() => void) = undefined; let unsubscribe: undefined | (() => void) = () => {};
let warn: jest.Mock; let warn: jest.Mock;
let error: jest.Mock; let error: jest.Mock;
const origWarning = console.warn; const origWarning = console.warn;
@@ -69,17 +69,14 @@ describe('sideeffect', () => {
events.push(`counter: ${s.counter.count}`); events.push(`counter: ${s.counter.count}`);
}, },
); );
store.dispatch({type: 'inc'}); store.dispatch({type: 'inc'});
store.dispatch({type: 'inc'}); store.dispatch({type: 'inc'});
expect(events.length).toBe(0); expect(events.length).toBe(0);
// arrive as a single effect // arrive as a single effect
jest.advanceTimersByTime(10); jest.advanceTimersByTime(10);
expect(events).toEqual(['counter: 2']); expect(events).toEqual(['counter: 2']);
// no more events arrive after unsubscribe // no more events arrive after unsubscribe
unsubscribe(); unsubscribe?.();
store.dispatch({type: 'inc'}); store.dispatch({type: 'inc'});
jest.advanceTimersByTime(10); jest.advanceTimersByTime(10);
expect(events).toEqual(['counter: 2']); expect(events).toEqual(['counter: 2']);
@@ -96,17 +93,13 @@ describe('sideeffect', () => {
events.push(`counter: ${count}`); events.push(`counter: ${count}`);
}, },
); );
store.dispatch({type: 'unrelated'}); store.dispatch({type: 'unrelated'});
expect(events.length).toBe(0); expect(events.length).toBe(0);
// unrelated event doesn't trigger // unrelated event doesn't trigger
jest.advanceTimersByTime(10); jest.advanceTimersByTime(10);
expect(events.length).toBe(0); expect(events.length).toBe(0);
// counter increment does // counter increment does
store.dispatch({type: 'inc'}); store.dispatch({type: 'inc'});
jest.advanceTimersByTime(10); jest.advanceTimersByTime(10);
expect(events).toEqual(['counter: 1']); expect(events).toEqual(['counter: 1']);
expect(warn).not.toBeCalled(); expect(warn).not.toBeCalled();
@@ -122,17 +115,13 @@ describe('sideeffect', () => {
events.push(`counter: ${number}`); events.push(`counter: ${number}`);
}, },
); );
store.dispatch({type: 'unrelated'}); store.dispatch({type: 'unrelated'});
expect(events.length).toBe(0); expect(events.length).toBe(0);
// unrelated event doesn't trigger // unrelated event doesn't trigger
jest.advanceTimersByTime(10); jest.advanceTimersByTime(10);
expect(events.length).toBe(0); expect(events.length).toBe(0);
// counter increment does // counter increment does
store.dispatch({type: 'inc'}); store.dispatch({type: 'inc'});
jest.advanceTimersByTime(10); jest.advanceTimersByTime(10);
expect(events).toEqual(['counter: 1']); expect(events).toEqual(['counter: 1']);
expect(warn).not.toBeCalled(); expect(warn).not.toBeCalled();
@@ -148,15 +137,13 @@ describe('sideeffect', () => {
throw new Error('oops'); throw new Error('oops');
}, },
); );
expect(() => { expect(() => {
store.dispatch({type: 'inc'}); store.dispatch({type: 'inc'});
}).not.toThrow(); }).not.toThrow();
jest.advanceTimersByTime(10); jest.advanceTimersByTime(10);
expect(error.mock.calls).toMatchInlineSnapshot(` expect(error.mock.calls).toMatchInlineSnapshot(`
Array [ [
Array [ [
"Error while running side effect 'test': Error: oops", "Error while running side effect 'test': Error: oops",
[Error: oops], [Error: oops],
], ],
@@ -164,27 +151,6 @@ describe('sideeffect', () => {
`); `);
}); });
test('warns about long running effects', async () => {
let done = false;
unsubscribe = sideEffect(
store,
{name: 'test', throttleMs: 10},
(s) => s,
() => {
const end = Date.now() + 100;
while (Date.now() < end) {
// block
}
done = true;
},
);
store.dispatch({type: 'inc'});
jest.advanceTimersByTime(200);
expect(done).toBe(true);
expect(warn.mock.calls[0][0]).toContain("Side effect 'test' took");
});
test('throttles correctly', async () => { test('throttles correctly', async () => {
unsubscribe = sideEffect( unsubscribe = sideEffect(
store, store,
@@ -194,50 +160,39 @@ describe('sideeffect', () => {
events.push(`counter: ${number}`); events.push(`counter: ${number}`);
}, },
); );
// Fires immediately // Fires immediately
store.dispatch({type: 'inc'}); store.dispatch({type: 'inc'});
jest.advanceTimersByTime(100); jest.advanceTimersByTime(100);
expect(events).toEqual(['counter: 1']); expect(events).toEqual(['counter: 1']);
// no new tick in the next 100 ms // no new tick in the next 100 ms
jest.advanceTimersByTime(300); jest.advanceTimersByTime(300);
store.dispatch({type: 'inc'}); store.dispatch({type: 'inc'});
jest.advanceTimersByTime(300); jest.advanceTimersByTime(300);
store.dispatch({type: 'inc'}); store.dispatch({type: 'inc'});
expect(events).toEqual(['counter: 1']); expect(events).toEqual(['counter: 1']);
jest.advanceTimersByTime(1000); jest.advanceTimersByTime(1000);
expect(events).toEqual(['counter: 1', 'counter: 3']); expect(events).toEqual(['counter: 1', 'counter: 3']);
// long time no effect, it will fire right away again // long time no effect, it will fire right away again
// N.b. we need call sleep here to create a timeout, as time wouldn't progress otherwise // N.b. we need call sleep here to create a timeout, as time wouldn't progress otherwise
const p = sleep(2000); const p = sleep(2000);
jest.advanceTimersByTime(2000); jest.advanceTimersByTime(2000);
await p; await p;
// ..but firing an event that doesn't match the selector doesn't reset the timer // ..but firing an event that doesn't match the selector doesn't reset the timer
store.dispatch({type: 'unrelated'}); store.dispatch({type: 'unrelated'});
expect(events).toEqual(['counter: 1', 'counter: 3']); expect(events).toEqual(['counter: 1', 'counter: 3']);
jest.advanceTimersByTime(100); jest.advanceTimersByTime(100);
store.dispatch({type: 'inc'}); store.dispatch({type: 'inc'});
store.dispatch({type: 'inc'}); store.dispatch({type: 'inc'});
jest.advanceTimersByTime(100); jest.advanceTimersByTime(100);
const p2 = sleep(2000); const p2 = sleep(2000);
jest.advanceTimersByTime(2000); jest.advanceTimersByTime(2000);
await p2; await p2;
expect(events).toEqual(['counter: 1', 'counter: 3', 'counter: 5']); expect(events).toEqual(['counter: 1', 'counter: 3', 'counter: 5']);
}); });
test('can fire immediately', async () => { test('can fire immediately', async () => {
store.dispatch({type: 'inc'}); store.dispatch({type: 'inc'});
store.dispatch({type: 'inc'}); store.dispatch({type: 'inc'});
unsubscribe = sideEffect( unsubscribe = sideEffect(
store, store,
{name: 'test', throttleMs: 1, fireImmediately: true}, {name: 'test', throttleMs: 1, fireImmediately: true},
@@ -246,7 +201,6 @@ describe('sideeffect', () => {
events.push(`counter: ${s.counter.count}`); events.push(`counter: ${s.counter.count}`);
}, },
); );
expect(events).toEqual(['counter: 2']); expect(events).toEqual(['counter: 2']);
store.dispatch({type: 'inc'}); store.dispatch({type: 'inc'});
store.dispatch({type: 'inc'}); store.dispatch({type: 'inc'});

View File

@@ -30,6 +30,6 @@ module.exports = {
...(process.env.COVERAGE_TEXT === 'detailed' ? ['text'] : []), ...(process.env.COVERAGE_TEXT === 'detailed' ? ['text'] : []),
], ],
testMatch: ['**/**.(node|spec).(js|jsx|ts|tsx)'], testMatch: ['**/**.(node|spec).(js|jsx|ts|tsx)'],
testEnvironment: 'jest-environment-jsdom-sixteen', testEnvironment: 'jsdom',
resolver: '<rootDir>/jest.resolver.js', resolver: '<rootDir>/jest.resolver.js',
}; };

View File

@@ -70,7 +70,7 @@
"@babel/eslint-parser": "^7.19.1", "@babel/eslint-parser": "^7.19.1",
"@jest-runner/electron": "^3.0.1", "@jest-runner/electron": "^3.0.1",
"@testing-library/react": "^12.1.4", "@testing-library/react": "^12.1.4",
"@types/jest": "^26.0.24", "@types/jest": "^29.5.1",
"@typescript-eslint/eslint-plugin": "^5.22.0", "@typescript-eslint/eslint-plugin": "^5.22.0",
"@typescript-eslint/parser": "^5.55.0", "@typescript-eslint/parser": "^5.55.0",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
@@ -93,15 +93,14 @@
"eslint-plugin-react": "^7.29.4", "eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.5.0", "eslint-plugin-react-hooks": "^4.5.0",
"eslint-plugin-rulesdir": "^0.2.1", "eslint-plugin-rulesdir": "^0.2.1",
"jest": "^26.6.3", "jest": "^29.5.0",
"jest-environment-jsdom-sixteen": "^2.0.0",
"jest-fetch-mock": "^3.0.3", "jest-fetch-mock": "^3.0.3",
"less": "^4.1.2", "less": "^4.1.2",
"patch-package": "^6.4.7", "patch-package": "^6.4.7",
"prettier": "^2.8.7", "prettier": "^2.8.7",
"pretty-format": "^27.5.0", "pretty-format": "^27.5.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"ts-jest": "^26.5.6", "ts-jest": "^29.1.0",
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "^4.9.5" "typescript": "^4.9.5"
}, },
@@ -116,6 +115,7 @@
"productName": "Flipper", "productName": "Flipper",
"resolutions": { "resolutions": {
"@jest-runner/electron/electron": "18.2.0", "@jest-runner/electron/electron": "18.2.0",
"jest-environment-jsdom": "29.5.0",
"minimist": "1.2.6", "minimist": "1.2.6",
"node-forge": "^1.0.6" "node-forge": "^1.0.6"
}, },

View File

@@ -104,7 +104,7 @@ describe('getWatchFolders', () => {
path.join(rootDir, 'local_module_2'), path.join(rootDir, 'local_module_2'),
); );
expect(resolvedFolders.map(normalizePath)).toMatchInlineSnapshot(` expect(resolvedFolders.map(normalizePath)).toMatchInlineSnapshot(`
Array [ [
"/test/root/local_module_2", "/test/root/local_module_2",
"/test/root/node_modules", "/test/root/node_modules",
"/test/root/plugins/fb/fb_plugin_module_1", "/test/root/plugins/fb/fb_plugin_module_1",

View File

@@ -66,11 +66,11 @@ test('$schema field is required', async () => {
fs.readFile = jest.fn().mockResolvedValue(new Buffer(json)); fs.readFile = jest.fn().mockResolvedValue(new Buffer(json));
const result = await runLint('dir'); const result = await runLint('dir');
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
Array [ [
". should have required property \\"$schema\\" pointing to a supported schema URI, e.g.: ". should have required property "$schema" pointing to a supported schema URI, e.g.:
{ {
\\"$schema\\": \\"https://fbflipper.com/schemas/plugin-package/v2.json\\", "$schema": "https://fbflipper.com/schemas/plugin-package/v2.json",
\\"name\\": \\"flipper-plugin-example\\", "name": "flipper-plugin-example",
... ...
}", }",
] ]
@@ -85,7 +85,7 @@ test('supported schema is required', async () => {
fs.readFile = jest.fn().mockResolvedValue(new Buffer(json)); fs.readFile = jest.fn().mockResolvedValue(new Buffer(json));
const result = await runLint('dir'); const result = await runLint('dir');
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
Array [ [
".$schema should point to a supported schema. Currently supported schemas: ".$schema should point to a supported schema. Currently supported schemas:
- https://fbflipper.com/schemas/plugin-package/v2.json", - https://fbflipper.com/schemas/plugin-package/v2.json",
] ]
@@ -100,7 +100,7 @@ test('name is required', async () => {
fs.readFile = jest.fn().mockResolvedValue(new Buffer(json)); fs.readFile = jest.fn().mockResolvedValue(new Buffer(json));
const result = await runLint('dir'); const result = await runLint('dir');
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
Array [ [
". should have required property 'name'", ". should have required property 'name'",
] ]
`); `);
@@ -113,8 +113,8 @@ test('name must start with "flipper-plugin-"', async () => {
fs.readFile = jest.fn().mockResolvedValue(new Buffer(json)); fs.readFile = jest.fn().mockResolvedValue(new Buffer(json));
const result = await runLint('dir'); const result = await runLint('dir');
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
Array [ [
"/name should start with \\"flipper-plugin-\\", e.g. \\"flipper-plugin-example\\"", "/name should start with "flipper-plugin-", e.g. "flipper-plugin-example"",
] ]
`); `);
}); });
@@ -126,8 +126,8 @@ test('keywords must contain "flipper-plugin"', async () => {
fs.readFile = jest.fn().mockResolvedValue(new Buffer(json)); fs.readFile = jest.fn().mockResolvedValue(new Buffer(json));
const result = await runLint('dir'); const result = await runLint('dir');
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
Array [ [
"/keywords should contain keyword \\"flipper-plugin\\"", "/keywords should contain keyword "flipper-plugin"",
] ]
`); `);
}); });
@@ -144,7 +144,7 @@ test('flippeBundlerEntry must point to an existing file', async () => {
fs.readFile = jest.fn().mockResolvedValue(new Buffer(json)); fs.readFile = jest.fn().mockResolvedValue(new Buffer(json));
const result = await runLint('dir'); const result = await runLint('dir');
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
Array [ [
"/flipperBundlerEntry should point to a valid file", "/flipperBundlerEntry should point to a valid file",
] ]
`); `);
@@ -159,9 +159,9 @@ test('multiple validation errors reported', async () => {
fs.readFile = jest.fn().mockResolvedValue(new Buffer(json)); fs.readFile = jest.fn().mockResolvedValue(new Buffer(json));
const result = await runLint('dir'); const result = await runLint('dir');
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
Array [ [
". should have required property 'flipperBundlerEntry'", ". should have required property 'flipperBundlerEntry'",
"/keywords should contain keyword \\"flipper-plugin\\"", "/keywords should contain keyword "flipper-plugin"",
] ]
`); `);
}); });

View File

@@ -72,31 +72,31 @@ test('converts package.json and adds dependencies', async () => {
expect(error).toBeUndefined(); expect(error).toBeUndefined();
expect(convertedPackageJsonString).toMatchInlineSnapshot(` expect(convertedPackageJsonString).toMatchInlineSnapshot(`
"{ "{
\\"$schema\\": \\"https://fbflipper.com/schemas/plugin-package/v2.json\\", "$schema": "https://fbflipper.com/schemas/plugin-package/v2.json",
\\"name\\": \\"flipper-plugin-fresco\\", "name": "flipper-plugin-fresco",
\\"id\\": \\"Fresco\\", "id": "Fresco",
\\"version\\": \\"1.0.0\\", "version": "1.0.0",
\\"main\\": \\"dist/bundle.js\\", "main": "dist/bundle.js",
\\"flipperBundlerEntry\\": \\"index.tsx\\", "flipperBundlerEntry": "index.tsx",
\\"license\\": \\"MIT\\", "license": "MIT",
\\"keywords\\": [ "keywords": [
\\"flipper-plugin\\", "flipper-plugin",
\\"images\\" "images"
], ],
\\"peerDependencies\\": { "peerDependencies": {
\\"flipper\\": \\"latest\\" "flipper": "latest"
}, },
\\"devDependencies\\": { "devDependencies": {
\\"flipper\\": \\"latest\\", "flipper": "latest",
\\"flipper-pkg\\": \\"latest\\" "flipper-pkg": "latest"
}, },
\\"scripts\\": { "scripts": {
\\"prepack\\": \\"yarn reset && yarn build && flipper-pkg lint && flipper-pkg bundle\\" "prepack": "yarn reset && yarn build && flipper-pkg lint && flipper-pkg bundle"
}, },
\\"title\\": \\"Images\\", "title": "Images",
\\"icon\\": \\"profile\\", "icon": "profile",
\\"bugs\\": { "bugs": {
\\"email\\": \\"example@test.com\\" "email": "example@test.com"
} }
}" }"
`); `);
@@ -107,27 +107,27 @@ test('converts package.json without changing dependencies', async () => {
expect(error).toBeUndefined(); expect(error).toBeUndefined();
expect(convertedPackageJsonString).toMatchInlineSnapshot(` expect(convertedPackageJsonString).toMatchInlineSnapshot(`
"{ "{
\\"$schema\\": \\"https://fbflipper.com/schemas/plugin-package/v2.json\\", "$schema": "https://fbflipper.com/schemas/plugin-package/v2.json",
\\"name\\": \\"flipper-plugin-fresco\\", "name": "flipper-plugin-fresco",
\\"id\\": \\"Fresco\\", "id": "Fresco",
\\"version\\": \\"1.0.0\\", "version": "1.0.0",
\\"main\\": \\"dist/bundle.js\\", "main": "dist/bundle.js",
\\"flipperBundlerEntry\\": \\"index.tsx\\", "flipperBundlerEntry": "index.tsx",
\\"license\\": \\"MIT\\", "license": "MIT",
\\"keywords\\": [ "keywords": [
\\"flipper-plugin\\", "flipper-plugin",
\\"images\\" "images"
], ],
\\"dependencies\\": { "dependencies": {
\\"flipper\\": \\"latest\\" "flipper": "latest"
}, },
\\"scripts\\": { "scripts": {
\\"prepack\\": \\"yarn reset && yarn build && flipper-pkg lint && flipper-pkg bundle\\" "prepack": "yarn reset && yarn build && flipper-pkg lint && flipper-pkg bundle"
}, },
\\"title\\": \\"Images\\", "title": "Images",
\\"icon\\": \\"profile\\", "icon": "profile",
\\"bugs\\": { "bugs": {
\\"email\\": \\"example@test.com\\" "email": "example@test.com"
} }
}" }"
`); `);

View File

@@ -12,7 +12,6 @@ import path from 'path';
import {getInstalledPluginDetails} from '../getPluginDetails'; import {getInstalledPluginDetails} from '../getPluginDetails';
import {pluginInstallationDir} from '../pluginPaths'; import {pluginInstallationDir} from '../pluginPaths';
import {normalizePath} from 'flipper-test-utils'; import {normalizePath} from 'flipper-test-utils';
import {mocked} from 'ts-jest/utils';
jest.mock('fs-extra'); jest.mock('fs-extra');
@@ -37,7 +36,7 @@ test('getPluginDetailsV1', async () => {
details.dir = normalizePath(details.dir); details.dir = normalizePath(details.dir);
details.entry = normalizePath(details.entry); details.entry = normalizePath(details.entry);
expect(details).toMatchInlineSnapshot(` expect(details).toMatchInlineSnapshot(`
Object { {
"bugs": undefined, "bugs": undefined,
"category": undefined, "category": undefined,
"deprecated": undefined, "deprecated": undefined,
@@ -80,7 +79,7 @@ test('getPluginDetailsV2', async () => {
details.dir = normalizePath(details.dir); details.dir = normalizePath(details.dir);
details.entry = normalizePath(details.entry); details.entry = normalizePath(details.entry);
expect(details).toMatchInlineSnapshot(` expect(details).toMatchInlineSnapshot(`
Object { {
"bugs": undefined, "bugs": undefined,
"category": undefined, "category": undefined,
"deprecated": undefined, "deprecated": undefined,
@@ -127,7 +126,7 @@ test('id used as title if the latter omited', async () => {
details.dir = normalizePath(details.dir); details.dir = normalizePath(details.dir);
details.entry = normalizePath(details.entry); details.entry = normalizePath(details.entry);
expect(details).toMatchInlineSnapshot(` expect(details).toMatchInlineSnapshot(`
Object { {
"bugs": undefined, "bugs": undefined,
"category": undefined, "category": undefined,
"deprecated": undefined, "deprecated": undefined,
@@ -173,7 +172,7 @@ test('name without "flipper-plugin-" prefix is used as title if the latter omite
details.dir = normalizePath(details.dir); details.dir = normalizePath(details.dir);
details.entry = normalizePath(details.entry); details.entry = normalizePath(details.entry);
expect(details).toMatchInlineSnapshot(` expect(details).toMatchInlineSnapshot(`
Object { {
"bugs": undefined, "bugs": undefined,
"category": undefined, "category": undefined,
"deprecated": undefined, "deprecated": undefined,
@@ -222,7 +221,7 @@ test('flipper-plugin-version is parsed', async () => {
details.dir = normalizePath(details.dir); details.dir = normalizePath(details.dir);
details.entry = normalizePath(details.entry); details.entry = normalizePath(details.entry);
expect(details).toMatchInlineSnapshot(` expect(details).toMatchInlineSnapshot(`
Object { {
"bugs": undefined, "bugs": undefined,
"category": undefined, "category": undefined,
"deprecated": undefined, "deprecated": undefined,
@@ -275,7 +274,7 @@ test('plugin type and supported devices parsed', async () => {
details.dir = normalizePath(details.dir); details.dir = normalizePath(details.dir);
details.entry = normalizePath(details.entry); details.entry = normalizePath(details.entry);
expect(details).toMatchInlineSnapshot(` expect(details).toMatchInlineSnapshot(`
Object { {
"bugs": undefined, "bugs": undefined,
"category": undefined, "category": undefined,
"deprecated": undefined, "deprecated": undefined,
@@ -299,19 +298,19 @@ test('plugin type and supported devices parsed', async () => {
"source": "src/index.tsx", "source": "src/index.tsx",
"specVersion": 2, "specVersion": 2,
"supportedApps": undefined, "supportedApps": undefined,
"supportedDevices": Array [ "supportedDevices": [
Object { {
"archived": false, "archived": false,
"os": "Android", "os": "Android",
}, },
Object { {
"os": "Android", "os": "Android",
"specs": Array [ "specs": [
"KaiOS", "KaiOS",
], ],
"type": "physical", "type": "physical",
}, },
Object { {
"os": "iOS", "os": "iOS",
"type": "emulator", "type": "emulator",
}, },
@@ -344,7 +343,7 @@ test('plugin type and supported apps parsed', async () => {
details.dir = normalizePath(details.dir); details.dir = normalizePath(details.dir);
details.entry = normalizePath(details.entry); details.entry = normalizePath(details.entry);
expect(details).toMatchInlineSnapshot(` expect(details).toMatchInlineSnapshot(`
Object { {
"bugs": undefined, "bugs": undefined,
"category": undefined, "category": undefined,
"deprecated": undefined, "deprecated": undefined,
@@ -367,18 +366,18 @@ test('plugin type and supported apps parsed', async () => {
"serverAddOnSource": undefined, "serverAddOnSource": undefined,
"source": "src/index.tsx", "source": "src/index.tsx",
"specVersion": 2, "specVersion": 2,
"supportedApps": Array [ "supportedApps": [
Object { {
"appID": "Messenger", "appID": "Messenger",
"os": "Android", "os": "Android",
"type": "emulator", "type": "emulator",
}, },
Object { {
"appID": "Instagram", "appID": "Instagram",
"os": "Android", "os": "Android",
"type": "physical", "type": "physical",
}, },
Object { {
"appID": "Facebook", "appID": "Facebook",
"os": "iOS", "os": "iOS",
"type": "emulator", "type": "emulator",
@@ -417,7 +416,7 @@ test('can merge two package.json files', async () => {
email: 'flippersupport@example.localhost', email: 'flippersupport@example.localhost',
}, },
}; };
const mockedFs = mocked(fs); const mockedFs = jest.mocked(fs);
mockedFs.readJson.mockImplementation((file) => { mockedFs.readJson.mockImplementation((file) => {
if (file === path.join(pluginPath, 'package.json')) { if (file === path.join(pluginPath, 'package.json')) {
return pluginBase; return pluginBase;
@@ -430,8 +429,8 @@ test('can merge two package.json files', async () => {
details.dir = normalizePath(details.dir); details.dir = normalizePath(details.dir);
details.entry = normalizePath(details.entry); details.entry = normalizePath(details.entry);
expect(details).toMatchInlineSnapshot(` expect(details).toMatchInlineSnapshot(`
Object { {
"bugs": Object { "bugs": {
"email": "flippersupport@example.localhost", "email": "flippersupport@example.localhost",
"url": "https://fb.com/groups/flippersupport", "url": "https://fb.com/groups/flippersupport",
}, },
@@ -450,7 +449,7 @@ test('can merge two package.json files', async () => {
"main": "dist/bundle.js", "main": "dist/bundle.js",
"name": "flipper-plugin-test", "name": "flipper-plugin-test",
"pluginType": "device", "pluginType": "device",
"publishedDocs": Object { "publishedDocs": {
"overview": true, "overview": true,
"setup": true, "setup": true,
}, },
@@ -460,19 +459,19 @@ test('can merge two package.json files', async () => {
"source": "src/index.tsx", "source": "src/index.tsx",
"specVersion": 2, "specVersion": 2,
"supportedApps": undefined, "supportedApps": undefined,
"supportedDevices": Array [ "supportedDevices": [
Object { {
"archived": false, "archived": false,
"os": "Android", "os": "Android",
}, },
Object { {
"os": "Android", "os": "Android",
"specs": Array [ "specs": [
"KaiOS", "KaiOS",
], ],
"type": "physical", "type": "physical",
}, },
Object { {
"os": "iOS", "os": "iOS",
"type": "emulator", "type": "emulator",
}, },

View File

@@ -16,7 +16,6 @@ import {
NpmPackageDescriptor, NpmPackageDescriptor,
} from '../getNpmHostedPlugins'; } from '../getNpmHostedPlugins';
import {getInstalledPlugins} from '../pluginInstaller'; import {getInstalledPlugins} from '../pluginInstaller';
import {mocked} from 'ts-jest/utils';
import type {Package} from 'npm-api'; import type {Package} from 'npm-api';
import {InstalledPluginDetails} from 'flipper-common'; import {InstalledPluginDetails} from 'flipper-common';
@@ -91,10 +90,10 @@ const updates: NpmPackageDescriptor[] = [
]; ];
test('annotatePluginsWithUpdates', async () => { test('annotatePluginsWithUpdates', async () => {
const getInstalledPluginsMock = mocked(getInstalledPlugins); const getInstalledPluginsMock = jest.mocked(getInstalledPlugins);
getInstalledPluginsMock.mockReturnValue(Promise.resolve(installedPlugins)); getInstalledPluginsMock.mockReturnValue(Promise.resolve(installedPlugins));
const getNpmHostedPluginsMock = mocked(getNpmHostedPlugins); const getNpmHostedPluginsMock = jest.mocked(getNpmHostedPlugins);
getNpmHostedPluginsMock.mockReturnValue(Promise.resolve(updates)); getNpmHostedPluginsMock.mockReturnValue(Promise.resolve(updates));
const res = await getUpdatablePlugins(); const res = await getUpdatablePlugins();
@@ -105,9 +104,9 @@ test('annotatePluginsWithUpdates', async () => {
version: res[0].version, version: res[0].version,
updateStatus: res[0].updateStatus, updateStatus: res[0].updateStatus,
}).toMatchInlineSnapshot(` }).toMatchInlineSnapshot(`
Object { {
"name": "flipper-plugin-hello", "name": "flipper-plugin-hello",
"updateStatus": Object { "updateStatus": {
"kind": "up-to-date", "kind": "up-to-date",
}, },
"version": "0.1.0", "version": "0.1.0",
@@ -119,9 +118,9 @@ test('annotatePluginsWithUpdates', async () => {
version: res[1].version, version: res[1].version,
updateStatus: res[1].updateStatus, updateStatus: res[1].updateStatus,
}).toMatchInlineSnapshot(` }).toMatchInlineSnapshot(`
Object { {
"name": "flipper-plugin-world", "name": "flipper-plugin-world",
"updateStatus": Object { "updateStatus": {
"kind": "update-available", "kind": "update-available",
"version": "0.3.0", "version": "0.3.0",
}, },

View File

@@ -50,8 +50,8 @@ test('it will merge equal rows', () => {
sendLogEntry(entry3); sendLogEntry(entry3);
expect(instance.rows.records()).toMatchInlineSnapshot(` expect(instance.rows.records()).toMatchInlineSnapshot(`
Array [ [
Object { {
"app": "X", "app": "X",
"count": 1, "count": 1,
"date": 2021-01-28T17:15:12.859Z, "date": 2021-01-28T17:15:12.859Z,
@@ -61,7 +61,7 @@ test('it will merge equal rows', () => {
"tid": 1, "tid": 1,
"type": "error", "type": "error",
}, },
Object { {
"app": "Y", "app": "Y",
"count": 2, "count": 2,
"date": 2021-01-28T17:15:17.859Z, "date": 2021-01-28T17:15:17.859Z,
@@ -71,7 +71,7 @@ test('it will merge equal rows', () => {
"tid": 3, "tid": 3,
"type": "warn", "type": "warn",
}, },
Object { {
"app": "X", "app": "X",
"count": 1, "count": 1,
"date": 2021-01-28T17:15:12.859Z, "date": 2021-01-28T17:15:12.859Z,
@@ -130,9 +130,9 @@ test('export / import plugin does work', async () => {
const data = await exportStateAsync(); const data = await exportStateAsync();
expect(data).toMatchInlineSnapshot(` expect(data).toMatchInlineSnapshot(`
Object { {
"logs": Array [ "logs": [
Object { {
"app": "X", "app": "X",
"count": 1, "count": 1,
"date": 2021-01-28T17:15:12.859Z, "date": 2021-01-28T17:15:12.859Z,
@@ -142,7 +142,7 @@ test('export / import plugin does work', async () => {
"tid": 1, "tid": 1,
"type": "error", "type": "error",
}, },
Object { {
"app": "Y", "app": "Y",
"count": 1, "count": 1,
"date": 2021-01-28T17:15:17.859Z, "date": 2021-01-28T17:15:17.859Z,

View File

@@ -47,11 +47,11 @@ test('Reducer correctly adds initial chunk', () => {
}); });
expect(instance.partialResponses.get()['1']).toMatchInlineSnapshot(` expect(instance.partialResponses.get()['1']).toMatchInlineSnapshot(`
Object { {
"followupChunks": Object {}, "followupChunks": {},
"initialResponse": Object { "initialResponse": {
"data": "hello", "data": "hello",
"headers": Array [], "headers": [],
"id": "1", "id": "1",
"index": 0, "index": 0,
"insights": null, "insights": null,
@@ -76,8 +76,8 @@ test('Reducer correctly adds followup chunk', () => {
data: 'hello', data: 'hello',
}); });
expect(instance.partialResponses.get()['1']).toMatchInlineSnapshot(` expect(instance.partialResponses.get()['1']).toMatchInlineSnapshot(`
Object { {
"followupChunks": Object { "followupChunks": {
"1": "hello", "1": "hello",
}, },
} }
@@ -113,13 +113,13 @@ test('Reducer correctly combines initial response and followup chunk', () => {
totalChunks: 2, totalChunks: 2,
}); });
expect(instance.partialResponses.get()).toMatchInlineSnapshot(` expect(instance.partialResponses.get()).toMatchInlineSnapshot(`
Object { {
"1": Object { "1": {
"followupChunks": Object {}, "followupChunks": {},
"initialResponse": Object { "initialResponse": {
"data": "aGVs", "data": "aGVs",
"headers": Array [ "headers": [
Object { {
"key": "Content-Type", "key": "Content-Type",
"value": "text/plain", "value": "text/plain",
}, },

View File

@@ -75,13 +75,13 @@ test('Can handle custom headers', async () => {
// verify internal storage // verify internal storage
expect(instance.columns.get().slice(-2)).toMatchInlineSnapshot(` expect(instance.columns.get().slice(-2)).toMatchInlineSnapshot(`
Array [ [
Object { {
"key": "request_header_test-header", "key": "request_header_test-header",
"title": "test-header (request)", "title": "test-header (request)",
"width": 200, "width": 200,
}, },
Object { {
"key": "response_header_second-test-header", "key": "response_header_second-test-header",
"title": "second-test-header (response)", "title": "second-test-header (response)",
"width": 200, "width": 200,
@@ -138,13 +138,13 @@ test('Can handle custom headers', async () => {
// verify internal storage // verify internal storage
expect(instance2.columns.get().slice(-2)).toMatchInlineSnapshot(` expect(instance2.columns.get().slice(-2)).toMatchInlineSnapshot(`
Array [ [
Object { {
"key": "request_header_test-header", "key": "request_header_test-header",
"title": "test-header (request)", "title": "test-header (request)",
"width": 200, "width": 200,
}, },
Object { {
"key": "response_header_second-test-header", "key": "response_header_second-test-header",
"title": "second-test-header (response)", "title": "second-test-header (response)",
"width": 200, "width": 200,

View File

@@ -28,13 +28,13 @@ test('It can store rows', () => {
}); });
expect(instance.rows.get()).toMatchInlineSnapshot(` expect(instance.rows.get()).toMatchInlineSnapshot(`
Object { {
"1": Object { "1": {
"id": 1, "id": 1,
"title": "Dolphin", "title": "Dolphin",
"url": "http://dolphin.png", "url": "http://dolphin.png",
}, },
"2": Object { "2": {
"id": 2, "id": 2,
"title": "Turtle", "title": "Turtle",
"url": "http://turtle.png", "url": "http://turtle.png",

View File

@@ -37,16 +37,16 @@ test('general plugin logic testing', async () => {
await sleep(1000); await sleep(1000);
expect(onSend).toBeCalledWith('getAllSharedPreferences', {}); expect(onSend).toBeCalledWith('getAllSharedPreferences', {});
expect(instance.sharedPreferences.get()).toMatchInlineSnapshot(` expect(instance.sharedPreferences.get()).toMatchInlineSnapshot(`
Object { {
"other_sample": Object { "other_sample": {
"changesList": Array [], "changesList": [],
"preferences": Object { "preferences": {
"SomeKey": 1337, "SomeKey": 1337,
}, },
}, },
"sample": Object { "sample": {
"changesList": Array [], "changesList": [],
"preferences": Object { "preferences": {
"Hello": "world", "Hello": "world",
}, },
}, },
@@ -77,16 +77,16 @@ test('general plugin logic testing', async () => {
5555, 5555,
); );
expect(instance.sharedPreferences.get()).toMatchInlineSnapshot(` expect(instance.sharedPreferences.get()).toMatchInlineSnapshot(`
Object { {
"other_sample": Object { "other_sample": {
"changesList": Array [], "changesList": [],
"preferences": Object { "preferences": {
"SomeKey": 5555, "SomeKey": 5555,
}, },
}, },
"sample": Object { "sample": {
"changesList": Array [ "changesList": [
Object { {
"deleted": false, "deleted": false,
"name": "SomeKey", "name": "SomeKey",
"preferences": "sample", "preferences": "sample",
@@ -94,7 +94,7 @@ test('general plugin logic testing', async () => {
"value": 5555, "value": 5555,
}, },
], ],
"preferences": Object { "preferences": {
"Hello": "world", "Hello": "world",
"SomeKey": 5555, "SomeKey": 5555,
}, },
@@ -120,20 +120,20 @@ test('general plugin logic testing', async () => {
instance.sharedPreferences.get().sample.preferences.SomeKey, instance.sharedPreferences.get().sample.preferences.SomeKey,
).toBeUndefined(); ).toBeUndefined();
expect(instance.sharedPreferences.get()).toMatchInlineSnapshot(` expect(instance.sharedPreferences.get()).toMatchInlineSnapshot(`
Object { {
"other_sample": Object { "other_sample": {
"changesList": Array [], "changesList": [],
"preferences": Object {}, "preferences": {},
}, },
"sample": Object { "sample": {
"changesList": Array [ "changesList": [
Object { {
"deleted": true, "deleted": true,
"name": "SomeKey", "name": "SomeKey",
"preferences": "sample", "preferences": "sample",
"time": 2, "time": 2,
}, },
Object { {
"deleted": false, "deleted": false,
"name": "SomeKey", "name": "SomeKey",
"preferences": "sample", "preferences": "sample",
@@ -141,7 +141,7 @@ test('general plugin logic testing', async () => {
"value": 5555, "value": 5555,
}, },
], ],
"preferences": Object { "preferences": {
"Hello": "world", "Hello": "world",
}, },
}, },

View File

@@ -63,17 +63,51 @@ console.debug = function () {
}; };
// make perf tools available in Node (it is available in Browser / Electron just fine) // make perf tools available in Node (it is available in Browser / Electron just fine)
const {PerformanceObserver, performance} = require('perf_hooks'); import {PerformanceObserver, performance} from 'perf_hooks';
Object.freeze(performance); // Object.freeze(performance);
Object.freeze(Object.getPrototypeOf(performance)); // Object.freeze(Object.getPrototypeOf(performance));
// Something in our unit tests is messing with the performance global // Something in our unit tests is messing with the performance global
// This fixes that..... // This fixes that.
let _performance = performance;
Object.defineProperty(global, 'performance', { Object.defineProperty(global, 'performance', {
get() { get() {
return performance; return _performance;
}, },
set() { set(value) {
throw new Error('Attempt to overwrite global.performance'); _performance = value;
if (typeof _performance.mark === 'undefined') {
_performance.mark = (_markName: string, _markOptions?) => {
return {
name: '',
detail: '',
duration: 0,
entryType: '',
startTime: 0,
toJSON() {},
};
};
}
if (typeof _performance.clearMarks === 'undefined') {
_performance.clearMarks = () => {};
}
if (typeof _performance.measure === 'undefined') {
_performance.measure = (
_measureName: string,
_startOrMeasureOptions?,
_endMark?: string | undefined,
) => {
return {
name: '',
detail: '',
duration: 0,
entryType: '',
startTime: 0,
toJSON() {},
};
};
}
}, },
}); });

View File

@@ -18,11 +18,10 @@ process.env.FLIPPER_TEST_RUNNER = 'true';
const {transform} = require('../babel-transformer/lib/transform-jest'); const {transform} = require('../babel-transformer/lib/transform-jest');
module.exports = { module.exports = {
process(src, filename, config, options) { process(src, filename, options) {
return transform({ return transform({
src, src,
filename, filename,
config,
options: {...options, isTestRunner: true}, options: {...options, isTestRunner: true},
}); });
}, },

File diff suppressed because it is too large Load Diff