[BUG] After upgrade to version - I'm getting the error with async functions: An async function or method in ES5/ES3 requires the 'Promise' constructor
See original GitHub issueContext:
- Playwright Version: 1.22.1
- Operating System: Windows
- Node.js version: 16.15.0
- Browser: AlL
- Extra: Tested with Webstorm IDE and with VSCode
Code Snippet
import test from "@playwright/test";
test.describe('Describe', async() => {
test.beforeEach(async ({page}) => {
await page.goto('');
});
test('Test', async({page}) => {
await page.locator('').click();
})
})
Describe the bug
The error started to appear after an upgrade to version 1.22. It requires the ‘Promise’ constructor. I didn’t see this error before an upgrade.
The error occurs in the VSCode:
And also in the Webstorm IDE:
I use the Playwright with typescript - should I need to take the advice of IDEs? Or maybe is it a bug? Because as I mentioned, I didn’t see these errors before an upgrade.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
ts An async function or method in ES5/ES3 requires the ...
[ts] An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor ......
Read more >Async and Await in JavaScript, the extension to a promise.
This function will operate a function asynchronously via the event loop using an implicit Promise to return its result. If you need a...
Read more >Handling “A”-synchronousity in JS | by Anil Kumar | Medium
[3] Async/Await (since ES8) => work on group of Promises + generators ... The then method attached to the Promise constructor is the...
Read more >Async/await - The Modern JavaScript Tutorial
So, async ensures that the function returns a promise, and wraps non-promises in it. Simple enough, right? But not only that. There's another ......
Read more >TypeScript errors and how to fix them
error TS1055: Type ' AxiosPromise ' is not a valid async function return type in ES5/ES3 because it does not refer to a...
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 Free
Top 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
@AlexKomanov You shouldn’t need lib. On 1.22, I used your code from https://github.com/microsoft/playwright/issues/14221#issue-1238645155 and your config https://github.com/microsoft/playwright/issues/14221#issuecomment-1128960207 but deleted the
lib
section. VSCode at first complained in the same way as your screenshot when I added the tsconfig, but I closed VSCode and re-opened and it was all good again. Can you check if closing and re-opening clears the errors?NB: Aside: if you then go and add a
process.env
call, the VSCode typing might complain, but this is related to https://github.com/microsoft/playwright/pull/14230 which will be fixed shortly in a patch release.Please re-open if I missed something or if restarting VSCode does not resolve the issue. Thanks!
I’m having the same issue,
tsc: Version 4.8.4
, andtsconfig.json
: