[Question] How to make test() use the same browser instance as the beforeAll. (Ignore test isolation)
See original GitHub issue~~UPDATE: Check my comment https://github.com/microsoft/playwright/issues/14508#issuecomment-1143274596~~ UPDATE 2: Check my comment https://github.com/microsoft/playwright/issues/14508#issuecomment-1144617999
I am trying to reuse the authentication example provided at the documentation for multiple .spec files (I know that is not recommended but it is necessary for my case)
Is there any recommendation of POM with fixture that I can do to solve that issue?
I want to avoid rewrite this part multiple times:
test.beforeAll(async ({ browser }) => {
// Create page once and sign in.
page = await browser.newPage();
await page.goto('https://github.com/login');
await page.fill('input[name="user"]', 'user');
await page.fill('input[name="password"]', 'password');
await page.click('text=Sign in');
});
Issue Analytics
- State:
- Created a year ago
- Comments:17 (7 by maintainers)
Top Results From Across the Web
Using same browser instance how to run the test suite
I'm having a testsuite(4 classes) which have common login for all classes. When I run the test suite, with first class alone having...
Read more >Unit testing fundamentals - Visual Studio (Windows)
Learn how Visual Studio Test Explorer provides a flexible and efficient way to run your unit tests and view their results.
Read more >Testing - Spring
This chapter covers Spring's support for integration testing and best practices for unit testing. The Spring team advocates test-driven ...
Read more >React end-to-end testing with Jest and Puppeteer
End-to-end tests simulate actual user actions and are designed to test how a real user would likely use the application. In React, E2E...
Read more >Write a synthetic test | Observability Guide [8.5] - Elastic
If there are any actions that should be done before or after journeys, you can use before , beforeAll , after , or...
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
@gegoncalves Yeah, I’d do it without fixtures! It should work reliably in case of single-page re-use.
I don’t know if I understood your question @aslushnikov correctly
So you are asking to use a global variable instead of the custom fixtures? I was thinking to use the custom fixtures due to the fact of being easier to just call the related pages through fixtures per test case than create an instance of each used POM
The
generalActions
class will be only the basic method we have. Ex:this method we use inside of each PO we have. Ex:
And after we have the fixture creation for each page that I shown here
Should I not use the custom fixture and just do every time a instance of each PO per test set file?
Probably I am doing something stupid without noticing 😅
For real, thanks for giving your time to help me with that