0

Following is the test case,

const browserActions = new BrowserActions();

describe('browserUtilities', () => {
  beforeEach(() => {
    global.browser = {
      getUrl: jest.fn(),
      getTitle: jest.fn(),
    };
  });

  it('should call deleteCookies on the browser', async () => {
    await browserActions.getUrlAndTitle();

    expect(global.browser.getUrl).toHaveBeenCalledTimes(2);
    expect(global.browser.getTitle).toHaveBeenCalledTimes(2);
  });
});

If I make this class .js file, then the code is running fine. But if I make this class .ts (TypeScript) file, I am getting the error as follows,

  e2e/test/support/action/browserUntil.spec.ts:7:12 - error TS2339: Property 'browser' does not exist on type 'typeof globalThis'.  

Tango
  • 95
  • 7
  • Does this answer your question?https://stackoverflow.com/questions/40743131/how-to-prevent-property-does-not-exist-on-type-global-with-jsdom-and-t – Lin Du May 31 '22 at 03:25

0 Answers0