Skip to content

[Docs]: page.route* aren't mocks but stubs #1737

@victorherraiz

Description

@victorherraiz

Page(s)

https://playwright.dev/java/docs/mock

Description

The Route API is currently implemented as a test double, but in my opinion, it functions more as a stub rather than a mock. I did not find (or perhaps I missed) any mechanism to verify interactions after test execution.

Mocks are superior in several scenarios, as they enable interaction verification and stricter control over test behavior. This is particularly useful for ensuring that specific methods are called with the expected arguments and produce better errors.

For reference, here are some well-known tools that differentiate between mocks and stubs effectively:

  • Mockito (Java)
  • WireMock
  • Sinon.js (JavaScript)
  • Martin Fowler's article: Mocks Aren't Stubs

It would be beneficial to enhance the Route API to support mock-like behavior, allowing developers to verify interactions and ensure precise request matching.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions