I am new to playwright and i have a question if anyone can help me. I use a random generated string and mailosaur to send emails and confirm accounts,(this is made in a register.setup.ts) and in a test .spec.ts i need the same email to recover the password. Is there a possibility that playwright knows how to have this random string across files? ๐ค
This thread is trying to answer question "Is there a possibility that playwright knows how to have this random string across files?"
Hi, sharing a variable between setup and tests can be achieved in a lot of different ways.
The easiest way would be to use environment variables https://playwright.dev/docs/test-global-setup-teardown#example
process.env.FOO = 'some data';
Personally, I would use fixtures to store email and have access to the string from setup and tests. There is an example code how to do this in https://playwright.dev/docs/test-fixtures#worker-scoped-fixtures
Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].