Ask
92
@nightbus_nina ·

vitest browser mode or just more playwright specs, 2 devs one repo Playwright

Two of us, one app, about 30k lines. 400 Vitest unit tests and 22 Playwright specs today.

I want component-level coverage for the fiddly design system parts - a data table with sticky columns and a combobox with keyboard nav - and jsdom lies about layout for both of them. Sticky positioning does not exist, and measuring anything returns zeros.

Vitest browser mode with Playwright underneath, or just write more Playwright specs against a route that mounts the component? We do not have the time to maintain three test setups.

7 answers Share
Report

Answering anonymously — a moderator will review it first.

  • @stropping_sal · 3w ago · 2 replies

    Split by failure mode rather than by tool.

    Component tests catch "this combination of props renders wrong". E2E catches "this button is wired to the wrong action". Your combobox is entirely the first kind: focus moves to the wrong option, the listbox measures wrong at the viewport edge, escape does not restore focus. None of those are reachable from a checkout flow test without twenty lines of setup.

    So: browser mode for the eight or ten widgets where jsdom actively lies, and nothing else. Do not migrate the 400 unit tests. Pure logic in jsdom is fine and it is fast.

    118
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
    • @wick_and_wax · 2w ago

      The corollary that saves the most time: write down the list of widgets that qualify, in the repo, and refuse to grow it. Every team that says "browser mode only for the hard components" ends up with 300 browser tests within a year unless somebody wrote the rule down.

      33
      Share
      Reply

      Answering anonymously — a moderator will review it first.

      Report
  • @overlap_owen · 3w ago · 2 replies

    We did the "Playwright against a component route" thing for about eighteen months. It works. Two things eventually pushed us off it:

    • roughly 700ms per spec versus 90ms, and it compounds
    • you cannot assert on props or callbacks, so you end up asserting on data-testid soup that exists purely for the test

    If the browsers are already installed for your e2e suite, browser mode is a much smaller step than it looks from the outside. Same locators, same trace viewer.

    68
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
    • @otis_haverford · 2w ago

      One caveat: the browser mode API has been moving between minor versions. Pin the version, read the changelog on upgrade, and expect an afternoon occasionally. For two people that is a real cost, just not a large one.

      37
      Share
      Reply

      Answering anonymously — a moderator will review it first.

      Report
  • @hollis_pike · 2w ago

    Contrarian data point: we deleted about 200 component tests and our production bug rate did not move. What did change is that a redesign stopped costing two days of test edits, because most of those tests asserted on markup rather than behaviour.

    For a two person team, e2e over the five flows that make money plus unit tests over the pure logic is a defensible whole strategy. Add component tests for the specific widgets that keep breaking, not as a layer.

    42
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
  • @fg_stall · 2w ago

    Whatever you choose: one runner, one command. Two test commands is fine. Three configs is where a two person team quietly starts skipping the one that is red.

    23
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
  • @secondhandamps · 2w ago

    Playwright does have its own component testing but it has been experimental for a long time and I would not build a small team's daily workflow on it right now.

    8
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report