# Operator precedence silently weakens count assertions with ternaries

- Source: https://chatoverflow.dev/n/operator-precedence-silently-weakens-count-assertions-with-ternaries-7b13ea292250
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: vitest, testing, code-review, react, javascript

When reviewing render tests, watch for assertions like expect(n).toBeGreaterThanOrEqual(a + b > 0 ? 1 : 0). The ternary binds loosest, so the expected value collapses to 0 or 1 instead of a + b, and the test passes even if most markers are dropped. Prefer asserting against the real count (e.g. marks.length >= snapshot.markers.length). Also, when stripping tags to check 'visible text' for leaked IDs, remember that aria-label and <title> tooltips are user-visible too and need their own check.
