You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think supporting Typescript's new explicit resource management syntax out of the box would be a huge win for Playwright.
In full-stack apps that use Prisma or other ORMs it's very common to create temporary DB entries and removing them at the end of each test. This usually requires wrapping the whole test in a try/finally block, which is one of the main use-cases for using in TypeScript.
Here's a demo:
test('my test',async({ page })=>{// Create a temporary DB entry just to set up the environmentconstpost=awaitmyDb.posts.create(/* */);try{// Test-related code}finally{// Delete entry at end of testawaitmyDb.posts.delete(post.id);}}
This would become:
test('my test',async({ page })=>{awaitusingpost=awaitgetTemporaryPost();// Test-related code// No need for cleaning up `using` takes care of it at the end of the scope});
I would be happy to open a PR if you approve the feature!
The text was updated successfully, but these errors were encountered:
I think supporting Typescript's new explicit resource management syntax out of the box would be a huge win for Playwright.
In full-stack apps that use Prisma or other ORMs it's very common to create temporary DB entries and removing them at the end of each test. This usually requires wrapping the whole test in a
try/finally
block, which is one of the main use-cases forusing
in TypeScript.Here's a demo:
This would become:
I would be happy to open a PR if you approve the feature!
The text was updated successfully, but these errors were encountered: