From c27a0ac1609b6e20ee1f0ed490dd7623b7305fad Mon Sep 17 00:00:00 2001 From: Inna Ianko Date: Mon, 23 Oct 2023 14:29:56 +0300 Subject: [PATCH] [INF-1500][E2E] Steps should be added only to the test block (#38) * [INF-1500][E2E] Steps should be added only to the test block * Added missing dot. --------- Co-authored-by: Inna Ianko --- e2e-testing.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/e2e-testing.md b/e2e-testing.md index ccad540..171f1c6 100644 --- a/e2e-testing.md +++ b/e2e-testing.md @@ -16,6 +16,7 @@ - [3.3. Use one spec file per one test](#33-use-one-spec-file-per-one-test) - [3.4. Before block should not contain common test data preparation](#34-before-block-should-not-contain-common-test-data-preparation) - [3.5. Test block should only contain test steps_and_assertions](#35-test-block-should-only-contain-test-steps-and-assertions) + - [3.6. Before block should not contain test steps](#36-before-block-should-not-contain-test-steps) - [4\. Assertions](#4-assertions) - [4.1 One assertion per one test step method](#41-one-assertion-per-one-test-step-method) - [4.2 Use expect for assertions](#42-use-expect-for-assertions) @@ -346,6 +347,45 @@ test('should allow to successfully create course', ``` +#### 3.6. Before block should not contain test steps + +Please do not add the test steps to the before block. All test steps should be added to the test block. + + +```typescript +// ❌ not recommended +test.beforeEach( async ({ page }) => { + signInPage = new SignInPage(page); + forgotPasswordPage = new ForgotPasswordPage(page); + + await signInPage.visit(); +}); + +test('should redirect to sign in page after submitting form', + async ({}) => { + await signInPage.clickResetPasswordLink(); + await forgotPasswordPage.assertOpened(); + ... + }); + + + +// ✅ recommended +test.beforeEach(({ page }) => { + signInPage = new SignInPage(page); + forgotPasswordPage = new ForgotPasswordPage(page); +}); + +test('should redirect to sign in page after submitting form', + async ({ }) => { + await signInPage.visit(); + await signInPage.clickResetPasswordLink(); + await forgotPasswordPage.assertOpened(); + ... + }); + +``` + 4\. Assertions --------------