Hello,
I am doing E2E of an application. I am generating inbox and emails via Mailslurp which I use to register and verify a user. On every register test new inbox and new email is generated for that test.
My goal is to complete the whole e2e process with that user. How can I store the data and use it across my test ?
For example:
Register & Verify user (here I take the data ) Login with the user from previous test Create a Site Create a schedule etc.
This thread is trying to answer question "How can I store the data generated by Mailslurp and use it across my tests for end-to-end testing of an application?"
Move 'everything' from the example test to one or more fixtures with scope 'worker' https://playwright.dev/docs/test-fixtures#worker-scoped-fixtures *this will use the same user on a single worker until there has been an error
here is an example code of one test
test.describe("Create credential", () => { let registerPage: RegisterPage let homePage : HomePage let CreateCredential : createCredential
test.beforeEach(async ({page}) => {
registerPage = new RegisterPage(page)
homePage = new HomePage(page)
CreateCredential = new createCredential(page)
await homePage.visit()
await homePage.fillLogInForm('[email protected]','Tester123#')
await homePage.pressSignInButton()
})
test('Create new credential',async ({page}) => {
await CreateCredential.createCredentialForUser('01231231', 'Tom Jones Bones')
await page.waitForTimeout(4000);
})
})
Ok, this is normally done in a global setup, try if you can find anything here: https://playwright.dev/docs/test-global-setup-teardown
Should be everything you need here: https://playwright.dev/docs/test-global-setup-teardown
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].