QA AND TEST AUTOMATION · PART 9 · NON-FUNCTIONAL TESTING · PERFORMANCE · 85 OF 112

Web Performance Testing: Core Web Vitals

Front-end performance from a tester's side: Core Web Vitals (LCP, INP, CLS) and their thresholds, lab data versus field data, Lighthouse run three times on ShopRung (mobile score 97 every time, but CLS 0.107, just over the limit, because the footer jumps as products render), the same shift caught by a Playwright test at phone width, DevTools throttling, and performance budgets in CI.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 67
  63. 68
  64. 69
  65. 70
  66. 71
  67. 72
  68. 73
  69. 74
  70. 75
  71. 76
  72. 77
  73. 78
  74. 79
  75. 80
  76. 81
  77. 82
  78. 83
  79. 84
  80. 85
  81. 86
  82. 87
  83. 88
  84. 89
  85. 90
  86. 91
  87. 92
  88. 93
  89. 94
  90. 95
  91. 96
  92. 97
  93. 98
  94. 99
  95. 100
  96. 101
  97. 102
  98. 103
  99. 104
  100. 105
  101. 106
  102. 107
  103. 108
  104. 109
  105. 110
  106. 111
  107. 112
1 / 11

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • LCP, INP, CLS
  • lab vs field
  • Lighthouse: 97 yet CLS 0.107
  • footer shift
  • Playwright check
  • budgets in CI

Notes

Core Web Vitals

Core Web Vitals are three numbers. Largest contentful paint: how long until the main content is visible; good is two and a half seconds or less. Interaction to next paint: how quickly the page reacts to taps and clicks; good is two hundred milliseconds or less. Cumulative layout shift: how much visible content jumps around while loading; good is zero point one or less. Each is judged at the seventy fifth percentile of real visits.

Good thresholds (p75)
LCP  Largest Contentful Paint
     main content visible
     good ≤ 2.5 s
INP  Interaction to Next Paint
     reacts to taps and clicks
     good ≤ 200 ms
CLS  Cumulative Layout Shift
     content jumping around
     good ≤ 0.1

Lab vs field

There are two kinds of data. Lab data comes from one controlled run, with Lighthouse, Playwright or WebPageTest; it is repeatable, which makes it good for CI and debugging. Field data comes from real users' browsers, through real user monitoring or Chrome's user experience report; it is what users actually feel. Interaction to next paint needs real interactions, so lab tools use total blocking time as a stand in.

Two kinds of data
  • lab: one controlled run (Lighthouse, Playwright, WebPageTest), repeatable, good for CI and debugging
  • field: real users' browsers (RUM, Chrome UX Report), what Google and users see
  • INP needs real interactions: lab uses TBT as a stand-in

Lighthouse

We ran Lighthouse on ShopRung's home page three times for each preset. The mobile preset simulates a mid range phone on a slow 4G connection. Mobile scored ninety seven, desktop ninety nine. The main content appeared in about one and a half seconds on mobile, with no blocking time, and the timings moved a little between runs. But look at layout shift: zero point one zero seven on mobile in every run, just over the zero point one limit. A ninety seven score can still hide a failing vital.

Lighthouse 12, 3 runs each
             mobile        desktop
score        97            99
FCP          1.1-1.3 s     0.3-0.4 s
LCP          1.4-1.6 s     0.4-0.5 s
TBT          0 ms          0 ms
CLS          0.107         0.061

mobile = a simulated mid-range
  phone on a slow 4G network

Find the cause

Lighthouse's layout shifts audit named the element: the footer, once on mobile and twice on desktop. ShopRung's page loads first, then JavaScript fetches the products and draws twelve cards, pushing the footer down. On a narrow phone screen that movement is large. The usual fixes reserve space before the data arrives: a minimum height for the product grid, or placeholder skeleton cards, plus width and height on images.

layout-shifts audit
mobile: body > footer.foot  0.107
desktop: the footer twice,
  0.054 + 0.007

why: the page loads, then
  JavaScript fetches products
  and draws 12 cards; the
  footer is pushed down
fix: reserve space (min-height,
  skeleton cards) before data

Test it

We turned this into a Playwright test. An init script observes layout shift entries and adds up their values, ignoring shifts caused by user input. The test loads the page, waits for twelve product cards, and expects a total under zero point one. At a phone width of four hundred and twelve pixels it failed with zero point one two six. Lighthouse, which also emulates a slow network, said zero point one zero seven; both are over the limit. At desktop width the test passed with zero point zero three seven.

cls.spec.ts
test.use({ viewport:
  { width: 412, height: 823 } });
addInitScript: PerformanceObserver
  type "layout-shift", sum values
  without recent input
goto("/"); expect 12 articles
expect(cls).toBeLessThan(0.1)

412 px wide:  0.126  ✗ failed
1280 px wide: 0.037  ✓ passed

DevTools

Testers should also feel it. In Chrome DevTools, throttle the network to slow 4G and slow the CPU four times, then record a page load or a click in the performance panel. Long tasks over fifty milliseconds show in red; they cause poor responsiveness. The performance panel shows live LCP, INP and CLS values, and the rendering tab can highlight areas that shift. Then try a real inexpensive phone.

Chrome DevTools
  • Network: throttle to slow 4G
  • Performance: CPU 4x slowdown, record a load or a click → long tasks (> 50 ms) in red
  • Performance panel shows live LCP, INP and CLS
  • Rendering: highlight layout shift regions
  • test on a real cheap phone too

Budgets in CI

Make it a gate. Lighthouse CI runs Lighthouse in the pipeline several times and asserts on results, such as LCP under two and a half seconds, CLS under zero point one and a minimum score. Size budgets limit JavaScript, images and fonts. Playwright checks like ours catch specific regressions. And in production, real user monitoring alerts when the seventy fifth percentile crosses a threshold.

Performance budgets
  • Lighthouse CI (lhci autorun): assert LCP < 2500, CLS < 0.1, score ≥ 0.9, run 3 times
  • size budgets: JS < 200 KB, images, fonts
  • Playwright checks like CLS
  • field: RUM alerts when p75 passes a threshold

Common mistakes

Mistakes. Testing only on a fast laptop and fast network. Trusting the overall score instead of the individual metrics; ShopRung scored ninety seven while failing layout shift. Drawing conclusions from one Lighthouse run, when results vary between runs. Using only lab data and never field data. And assuming a fast server means a fast page.

Avoid these
  • testing only on a fast laptop and fast network
  • trusting the score, not the individual metrics
  • one Lighthouse run (it varies)
  • lab only, never field data
  • server speed = page speed

Say it like this

In the interview: I test against Core Web Vitals, LCP up to two and a half seconds, INP up to two hundred milliseconds, and CLS up to zero point one at the seventy fifth percentile. I run Lighthouse with the mobile preset several times and read each metric, not just the score, add Playwright checks for specific problems like layout shift, put budgets in CI with Lighthouse CI, and confirm with field data from real users.

In the interview
  • "Core Web Vitals: LCP ≤ 2.5 s, INP ≤ 200 ms, CLS ≤ 0.1 at p75.
  • Lighthouse on the mobile preset, several runs, checking each metric, not just the score;
  • Playwright checks for things
  • like layout shift; Lighthouse CI
  • budgets in the pipeline; and field data from RUM to confirm
  • what real users feel."

Interview questions

Q1What are the Core Web Vitals?

LCP (loading, good ≤ 2.5 s), INP (responsiveness, good ≤ 200 ms) and CLS (visual stability, good ≤ 0.1), measured at the 75th percentile.

Q2What is the difference between lab and field data?

Lab data comes from controlled runs like Lighthouse and is repeatable; field data comes from real users' browsers and shows actual experience.

Q3What causes layout shift?

Content that appears or resizes after first render without reserved space: late-loading data, images without dimensions, ads, web fonts.

Q4How can a high Lighthouse score hide a problem?

The score is a weighted mix; ShopRung scored 97 on mobile while its CLS of 0.107 failed the 0.1 threshold.

Q5How do you measure CLS in a Playwright test?

Register a PerformanceObserver for layout-shift entries in an init script, sum values without recent input, then assert the total.

Q6Why does Lighthouse use TBT instead of INP?

INP needs real user interactions; total blocking time measures main-thread blocking during load as a lab stand-in.

Q7How do you add web performance to CI?

Lighthouse CI with assertions on metrics and scores over several runs, size budgets, and targeted Playwright checks.

Q8Why test with throttling?

Developer machines and networks are much faster than many users' phones; throttling CPU and network shows what they experience.