Skip to content

Commit

Permalink
test number of consoler logs on plugin render
Browse files Browse the repository at this point in the history
Summary: the number of logs in the console is out of hand. Lets not make it worse

Reviewed By: lblasa

Differential Revision: D53476216

fbshipit-source-id: 06e4fe21ba09c3a11c292706c66fa3a16528afd6
  • Loading branch information
antonk52 authored and facebook-github-bot committed Feb 6, 2024
1 parent 7af0ec5 commit fce8715
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions desktop/flipper-ui/src/__tests__/PluginContainer.node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ class TestPlugin extends FlipperPlugin<any, any, any> {
}
}

let errorSpy: any, warnSpy: any, infoSpy: any;

beforeAll(() => {
errorSpy = jest.spyOn(console, 'error');
warnSpy = jest.spyOn(console, 'warn');
infoSpy = jest.spyOn(console, 'info');
});

afterAll(() => {
errorSpy.mockRestore();
warnSpy.mockRestore();
infoSpy.mockRestore();
});

test('Plugin container can render plugin and receive updates', async () => {
const {renderer, sendMessage, act} =
await renderMockFlipperWithPlugin(TestPlugin);
Expand Down Expand Up @@ -110,6 +124,23 @@ test('Plugin container can render plugin and receive updates', async () => {
expect((await renderer.findByTestId('counter')).textContent).toBe('2');
});

test('Number of times console errors/warning during plugin render', async () => {
await renderMockFlipperWithPlugin(TestPlugin);

expect(errorSpy.mock.calls).toEqual([
[
"Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot",
],
]);
expect(warnSpy.mock.calls).toEqual([]);
expect(infoSpy.mock.calls).toEqual([
[
"Received plugins from 'TestApp' on device 'MockAndroidDevice'",
['TestPlugin'],
],
]);
});

// TODO(T119353406): Disabled due to flakiness.
test.skip('PluginContainer can render Sandy plugins', async () => {
let renders = 0;
Expand Down

0 comments on commit fce8715

Please sign in to comment.