So I am using playwright/test with Typescript
I have a testapp.ts setup which contains all my methods eg for logging in, navigating etc Inside my test example.spec.ts each test looks like this:
const testapp = new TestApp(page);
await testapp.methodName();
});
I tried to put the const testapp = new TestApp(page); inside the beforeEach so I don't have to start every test putting in that line, but I get an error:
TypeError: Cannot read properties of undefined (reading 'testName')
jest lets you put the new TestApp(page) inside the beforeEach but not playwright/test
Is there any way to do this? Or Do I have to switch to jest?
Putting it in global-setup is not an option as I don't want to create a new browser page for each test my goal is to do end to end
Open one browser for each test suite and login, and then each test will execute on that session. Currently, it's working that way, except I have to put the new TestApp(page) inside every test