How to fix TS2339: Property 'browser' does not exist on type 'Global'?
See original GitHub issueDear 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:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
it’s not an elegant solution, but you can add this line to solve this problem.
@sinapsist You can get TS definition for jest-puppeteer from this package: https://www.npmjs.com/package/@types/jest-environment-puppeteer