Mock chrome.devtools.panel on jest/angular application

Viewed 10

I'm writing an application that extends the chrome dev tools. On the ngOnInit method of the main component, I have this

public ngOnInit(): void {
    chrome.devtools.panels.create(
      'extension-tool',
      'favicon,ico',
      'index.html#/devtool-panel',
      panel => {
        console.log('Panel Created', panel);
      },
    );
  }

This works fine, but when I add basic testing, I receive the error:

Reference error: chrome is not defined

I was told that I could create something like this

global.chrome = {
    devtools: {
        panels: {
           create: jest.fn()
        }
    }
};

But the problem is that it complains because I have to add ALL the fields of chrome.devtools.panels. And that it's HUGE.

Anyone knows a better, quicker way to mock-up the chrome.devtools.panels object on Jest?

Thanks in advance,

0 Answers
Related