playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Docs]: Component testing "best practices" or "pitfalls"

Open sand4rt opened this issue 1 year ago • 1 comments

Page(s)

Page: https://playwright.dev/docs/next/test-components#update

I think these topics would be useful to mention:

  • Determine what to test
  • Determine what not to test (implementation details)
  • How to name tests
  • Use the appropriate locator
  • Emphasise emulation over mocking
  • Avoid nesting / describe blocks
  • Avoid unnecessary abstractions (Test isolation)
  • Ensure your test can fail

@dgozman do you have other topics/changes in mind?

Description

Suggestion from @dgozman to include a "best practices" or "pitfalls" section for component testing: https://github.com/microsoft/playwright/issues/31339#issuecomment-2174162872. I've created a ticket to track this so I don't forget.

sand4rt avatar Jun 18 '24 11:06 sand4rt

do you have other topics/changes in mind?

This looks like a good starting point. If anything, some of these topics might be relevant in e2e best practices as well.

dgozman avatar Jun 18 '24 14:06 dgozman