What abstraction would you introduce for these checkout tests?

Instruction: Show the structure you would use and one example test. Explain what you would share now and what you would keep separate.

Context:

Five tests repeat entering a street and postal code on the fictional /checkout/shipping page. Two cover valid addresses; three cover different validation outcomes. The page has a form named Shipping address, labels Street and Postal code, and a Continue button. A valid submission renders data-testid="shipping-summary" as street, comma-space and postal code. The suite will soon add a billing-address form with some different fields. Propose the abstraction, if any, you would introduce now. A base URL is configured; the fixture starts with an empty shipping form.

Updated

Official answer available

Read the opening below, then unlock the full answer and practical guidance.

I would extract the repeated shipping interaction into a small form component or helper. It would own the stable locators and named user actions, while each test states its scenario-specific expected outcome...

Related Questions