question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to fix TS2339: Property 'browser' does not exist on type 'Global'?

See original GitHub issue

Dear jest-puppeteer community,

I am using typescript and configured jest-puppeteer using next configuration: (without configuring custom setup and teardown)

jest-puppeteer.config.js

module.exports = {
    launch: {
        headless: false,
    }
}

jest.breakpoints.config.js

module.exports = {
    preset: 'jest-puppeteer',
    testRegex: './breakpoints/',
}

And test file:

beforeAll(async () => {
    //  Getting TS2339: Property 'browser' does not exist on type 'Global
    page = await global.browser.newPage();
    script = `getComputedStyle(document.querySelector('img[alt="Google"]', null)).display`;
});

afterAll(async () => {
    await page.close();
});

describe('Breakpoint test', () => {
    it('should not display right nav at mobile breakpoint', async () => {
        page.setViewport({ width: 400, height: 600 });
        await page.goto('https://www.google.com/');
        const result = await page.evaluate(script);
        expect(result).not.toBeNull()
    }, 10000);
});

And it works. but I am getting this TS2339 tslint error. Could someone, please, help me to understand how to fix it without disabling TS-lint on this line.

Thank you!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

6reactions
xiaoyuhencommented, Apr 6, 2019

it’s not an elegant solution, but you can add this line to solve this problem.

declare var global: any
1reaction
lukaszfiszercommented, Apr 15, 2019

@sinapsist You can get TS definition for jest-puppeteer from this package: https://www.npmjs.com/package/@types/jest-environment-puppeteer

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to prevent "Property '...' does not exist on type 'Global ...
Original Answer To Avoid Error. Put this at the top of your typescript file const globalAny:any = global;. Then use globalAny instead.
Read more >
How to fix 'Property does not exist on type Window in ...
Fixing the 'Property does not exist on type Window in TypeScript' error ... Fortunately for us, the fix is quite simple and involves...
Read more >
How To Fix The "Property does not exist on type Window ...
First off, make sure you truly need a global variable on the window object. In many cases, this can be replaced with a...
Read more >
TypeScript “Property does not exist on type” | by Mike Diaz
TS2339 : Property does not exist on type. Let's look at the code that threw this error: const diazcoConfig: CustomClientConfig = { SIGNUP_EVENT: ......
Read more >
property 'contains' does not exist on type 'never'. - You.com
ts declare global { interface Buffer {} } export declare function printStuff(str: string): void; /** * NOTE: Only works in Node.js */ export...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found