{"id":4823,"date":"2025-08-26T13:18:07","date_gmt":"2025-08-26T13:18:07","guid":{"rendered":"https:\/\/uplatz.com\/blog\/?p=4823"},"modified":"2025-08-27T02:33:17","modified_gmt":"2025-08-27T02:33:17","slug":"cypress-pocket-book","status":"publish","type":"post","link":"https:\/\/uplatz.com\/blog\/cypress-pocket-book\/","title":{"rendered":"Cypress Pocket Book"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/uplatz.com\/blog\/wp-content\/uploads\/2025\/08\/6-1024x576.png\" alt=\"Cypress Pocket Book\" width=\"840\" height=\"473\" class=\"alignnone size-large wp-image-4838\" srcset=\"https:\/\/uplatz.com\/blog\/wp-content\/uploads\/2025\/08\/6-1024x576.png 1024w, https:\/\/uplatz.com\/blog\/wp-content\/uploads\/2025\/08\/6-300x169.png 300w, https:\/\/uplatz.com\/blog\/wp-content\/uploads\/2025\/08\/6-768x432.png 768w, https:\/\/uplatz.com\/blog\/wp-content\/uploads\/2025\/08\/6.png 1280w\" sizes=\"auto, (max-width: 840px) 100vw, 840px\" \/><br \/>\n<!-- Cypress Pocket Book \u2014 Uplatz (50 Cards, Wide Layout, Readable Code, Scoped Styles) --><\/p>\n<div style=\"margin: 16px 0;\">\n<style>\n    .wp-nodejs-pb { font-family: Arial, sans-serif; max-width: 1320px; margin:0 auto; }\n    .wp-nodejs-pb .heading{\n      background: linear-gradient(135deg, #e0f2fe, #ccfbf1); \/* lighter gradient *\/\n      color:#0f172a; padding:22px 24px; border-radius:14px;\n      text-align:center; margin-bottom:18px; box-shadow:0 8px 20px rgba(0,0,0,.08);\n      border:1px solid #cbd5e1;\n    }\n    .wp-nodejs-pb .heading h2{ margin:0; font-size:2.1rem; letter-spacing:.2px; }\n    .wp-nodejs-pb .heading p{ margin:6px 0 0; font-size:1.02rem; opacity:.9; }<\/p>\n<p>    \/* Wide, dense grid *\/\n    .wp-nodejs-pb .grid{\n      display:grid; gap:14px;\n      grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));\n    }\n    @media (min-width:1200px){\n      .wp-nodejs-pb .grid{ grid-template-columns: repeat(3, 1fr); }\n    }<\/p>\n<p>    .wp-nodejs-pb .section-title{\n      grid-column:1\/-1; background:#f8fafc; border-left:8px solid #0ea5e9;\n      padding:12px 16px; border-radius:10px; font-weight:700; color:#0f172a; font-size:1.08rem;\n      box-shadow:0 2px 8px rgba(0,0,0,.05); border:1px solid #e2e8f0;\n    }\n    .wp-nodejs-pb .card{\n      background:#ffffff; border-left:6px solid #0ea5e9;\n      padding:18px; border-radius:12px;\n      box-shadow:0 6px 14px rgba(0,0,0,.06);\n      transition:transform .12s ease, box-shadow .12s ease;\n      border:1px solid #e5e7eb;\n    }\n    .wp-nodejs-pb .card:hover{ transform: translateY(-3px); box-shadow:0 10px 22px rgba(0,0,0,.08); }\n    .wp-nodejs-pb .card h3{ margin:0 0 10px; font-size:1.12rem; color:#0f172a; }\n    .wp-nodejs-pb .card p{ margin:0; font-size:.96rem; color:#334155; line-height:1.62; }<\/p>\n<p>    \/* Color helpers *\/\n    .bg-blue { border-left-color:#0ea5e9 !important; background:#f0f9ff !important; }\n    .bg-green{ border-left-color:#10b981 !important; background:#f0fdf4 !important; }\n    .bg-amber{ border-left-color:#f59e0b !important; background:#fffbeb !important; }\n    .bg-violet{ border-left-color:#8b5cf6 !important; background:#f5f3ff !important; }\n    .bg-rose{ border-left-color:#ef4444 !important; background:#fff1f2 !important; }\n    .bg-cyan{ border-left-color:#06b6d4 !important; background:#ecfeff !important; }\n    .bg-lime{ border-left-color:#16a34a !important; background:#f0fdf4 !important; }\n    .bg-orange{ border-left-color:#f97316 !important; background:#fff7ed !important; }\n    .bg-indigo{ border-left-color:#6366f1 !important; background:#eef2ff !important; }\n    .bg-emerald{ border-left-color:#22c55e !important; background:#ecfdf5 !important; }\n    .bg-slate{ border-left-color:#334155 !important; background:#f8fafc !important; }<\/p>\n<p>    \/* Utilities *\/\n    .tight ul{ margin:0; padding-left:18px; }\n    .tight li{ margin:4px 0; }\n    .mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }\n    .kbd{ background:#e5e7eb; border:1px solid #cbd5e1; padding:1px 6px; border-radius:6px; font-family:ui-monospace,monospace; font-size:.88em; }\n    .muted{ color:#64748b; }\n    .wp-nodejs-pb code{ background:#f1f5f9; padding:0 4px; border-radius:4px; border:1px solid #e2e8f0; }\n    .wp-nodejs-pb pre{\n      background:#f5f5f5; color:#111827; border:1px solid #e5e7eb;\n      padding:12px; border-radius:8px; overflow:auto; font-size:.92rem; line-height:1.55;\n    }\n    .q{font-weight:700;}\n    .qa p{ margin:8px 0; }\n    .qa b{ color:#0f172a; }\n  <\/style>\n<div class=\"wp-nodejs-pb\">\n<div class=\"heading\">\n<h2>Cypress Pocket Book \u2014 Uplatz<\/h2>\n<p>      50 deep-dive flashcards \u2022 Wide layout \u2022 Fewer scrolls \u2022 20+ Interview Q&amp;A \u2022 Readable code examples\n    <\/p><\/div>\n<div class=\"grid\">\n      <!-- ===================== SECTION 1 ===================== --><\/p>\n<div class=\"section-title\">Section 1 \u2014 Fundamentals<\/div>\n<div class=\"card bg-blue\">\n<h3>1) What is Cypress?<\/h3>\n<p>        JavaScript end-to-end and component testing framework for the web. Runs in the browser with automatic waits, time-travel UI, and great DX for modern SPAs.<\/p>\n<pre><code class=\"mono\">npm i -D cypress\r\nnpx cypress open   # interactive\r\nnpx cypress run    # headless CI<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-green\">\n<h3>2) E2E vs Component Testing<\/h3>\n<p>        E2E automates full browser journeys; Component tests mount UI components in isolation. Use both for confidence and fast feedback.<\/p>\n<pre><code class=\"mono\"># In cypress.config.ts\r\ne2e: { baseUrl: \"http:\/\/localhost:3000\" }\r\ncomponent: { devServer: { framework: \"react\" } }<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-amber\">\n<h3>3) Folder Structure<\/h3>\n<p>        Tests live under <code>cypress\/e2e\/<\/code> and <code>cypress\/fixtures\/<\/code>, with support files and plugins in <code>cypress\/support\/<\/code>.<\/p>\n<pre><code class=\"mono\">cypress\/\r\n  e2e\/login.cy.ts\r\n  fixtures\/user.json\r\n  support\/commands.ts<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-violet\">\n<h3>4) First Test<\/h3>\n<p>        Visit, select, assert. Cypress auto-retries until assertions pass or timeout hits\u2014avoid manual sleeps.<\/p>\n<pre><code class=\"mono\">describe('Home', () =&gt; {\r\n  it('shows header', () =&gt; {\r\n    cy.visit('\/');\r\n    cy.contains('Welcome').should('be.visible');\r\n  });\r\n});<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-rose\">\n<h3>5) Best Selectors<\/h3>\n<p>        Prefer stable <code>data-cy<\/code> (or <code>data-testid<\/code>) attributes over classes\/IDs that change with styling.<\/p>\n<pre><code class=\"mono\">&lt;button data-cy=\"login-submit\"&gt;Sign in&lt;\/button&gt;\r\ncy.get('[data-cy=login-submit]').click()<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-cyan\">\n<h3>6) Assertions<\/h3>\n<p>        Use Chai\/jQuery assertions; Cypress chains are retried. <code>.should()<\/code> re-queries; <code>.then()<\/code> yields a value.<\/p>\n<pre><code class=\"mono\">cy.get('.toast').should('contain.text','Saved')<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-lime\">\n<h3>7) Commands &amp; Yielding<\/h3>\n<p>        Cypress commands are async and yield subjects to the next command. Don\u2019t assign to variables\u2014chain instead.<\/p>\n<pre><code class=\"mono\">cy.get('input').type('hello').should('have.value','hello')<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-orange\">\n<h3>8) Timeouts &amp; Waiting<\/h3>\n<p>        Avoid <code>cy.wait(1000)<\/code>. Prefer implicit waits via <code>.should()<\/code> or network waits via aliases.<\/p>\n<pre><code class=\"mono\">cy.intercept('GET','\/api\/user').as('user');\r\ncy.wait('@user').its('response.statusCode').should('eq',200)<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-indigo\">\n<h3>9) Cross-Browser<\/h3>\n<p>        Run in Chrome\/Edge (Chromium) and Firefox. Validate critical flows in both; align CI matrix accordingly.<\/p>\n<pre><code class=\"mono\">npx cypress run --browser chrome\r\nnpx cypress run --browser firefox<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-emerald\">\n<h3>10) Q&amp;A \u2014 \u201cCypress vs Selenium?\u201d<\/h3>\n<p>        <span class=\"q\">Answer:<\/span> Cypress runs inside the browser with automatic waits and a rich dev UI; Selenium\/WebDriver controls browsers externally and supports more environments\/languages.\n      <\/div>\n<p>      <!-- ===================== SECTION 2 ===================== --><\/p>\n<div class=\"section-title\">Section 2 \u2014 Core APIs &amp; Patterns<\/div>\n<div class=\"card bg-blue\">\n<h3>11) Visiting &amp; Navigation<\/h3>\n<p>        Set a <code>baseUrl<\/code> and use relative paths. Use <code>cy.location()<\/code> and <code>cy.url()<\/code> to assert navigation.<\/p>\n<pre><code class=\"mono\">cy.visit('\/dashboard')\r\ncy.location('pathname').should('eq','\/dashboard')<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-green\">\n<h3>12) Forms<\/h3>\n<p>        Type, select, check, and submit with assertions on disabled\/enabled states.<\/p>\n<pre><code class=\"mono\">cy.get('[data-cy=email]').type('a@b.co')\r\ncy.get('[data-cy=agree]').check().should('be.checked')<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-amber\">\n<h3>13) Fixtures<\/h3>\n<p>        Load JSON from <code>cypress\/fixtures<\/code> for test data and network stubs.<\/p>\n<pre><code class=\"mono\">cy.fixture('user.json').then(u =&gt; {\r\n  cy.get('[data-cy=email]').type(u.email)\r\n})<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-violet\">\n<h3>14) Custom Commands<\/h3>\n<p>        Abstract repeated flows (e.g., login) into <code>cypress\/support\/commands.ts<\/code>.<\/p>\n<pre><code class=\"mono\">\/\/ support\/commands.ts\r\nCypress.Commands.add('login', (email, pass) =&gt; {\r\n  cy.request('POST','\/api\/login',{ email, pass });\r\n});\r\ndeclare global { namespace Cypress { interface Chainable { login(email:string, pass:string): Chainable&lt;void&gt; }}}<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-rose\">\n<h3>15) Network Control: cy.intercept()<\/h3>\n<p>        Spy or stub requests\/responses; alias and wait deterministically.<\/p>\n<pre><code class=\"mono\">cy.intercept('GET','\/api\/todos', { fixture:'todos.json' }).as('todos')\r\ncy.visit('\/todos')\r\ncy.wait('@todos')<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-cyan\">\n<h3>16) API Testing: cy.request()<\/h3>\n<p>        Hit APIs directly without UI; assert status and body.<\/p>\n<pre><code class=\"mono\">cy.request('POST','\/api\/items',{ name:'Book' })\r\n  .its('status').should('eq',201)<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-lime\">\n<h3>17) State &amp; Sessions<\/h3>\n<p>        Use <code>cy.session()<\/code> to cache login across specs for speed; clear cookies\/localStorage between tests for isolation.<\/p>\n<pre><code class=\"mono\">cy.session([email,pass], () =&gt; cy.login(email,pass))<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-orange\">\n<h3>18) Clocks &amp; Timers<\/h3>\n<p>        Control time with <code>cy.clock()<\/code> and <code>cy.tick()<\/code> for deterministic tests.<\/p>\n<pre><code class=\"mono\">cy.clock(Date.UTC(2025,0,1))\r\ncy.tick(60000)<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-indigo\">\n<h3>19) Files: Upload\/Download<\/h3>\n<p>        Upload via input elements; verify downloaded files exist and content matches.<\/p>\n<pre><code class=\"mono\">cy.get('input[type=file]').selectFile('cypress\/fixtures\/pic.png')<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-emerald\">\n<h3>20) Q&amp;A \u2014 \u201cWhen to stub vs hit real API?\u201d<\/h3>\n<p>        <span class=\"q\">Answer:<\/span> Stub for edge cases, speed, and determinism; hit real APIs for contract confidence and auth flows in a dedicated suite\/environment.\n      <\/div>\n<p>      <!-- ===================== SECTION 3 ===================== --><\/p>\n<div class=\"section-title\">Section 3 \u2014 Strategy, Structure, CI &amp; Data<\/div>\n<div class=\"card bg-blue\">\n<h3>21) Test Pyramid<\/h3>\n<p>        Heavier unit\/component; fewer e2e happy paths; a handful of critical journeys. Keep e2e stable and fast.<\/p>\n<pre><code class=\"mono\">Unit &gt; Component &gt; E2E (counts)<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-green\">\n<h3>22) Spec Design<\/h3>\n<p>        One feature per spec, independent setup, no hidden coupling. Name specs by feature to aid reporting.<\/p>\n<pre><code class=\"mono\">checkout.cy.ts, profile.cy.ts<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-amber\">\n<h3>23) Env &amp; Secrets<\/h3>\n<p>        Use <code>cypress.env.json<\/code> or OS vars (<code>CYPRESS_*<\/code>). Never commit secrets; inject via CI.<\/p>\n<pre><code class=\"mono\">CYPRESS_baseUrl=https:\/\/staging.example.com<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-violet\">\n<h3>24) Config (TypeScript)<\/h3>\n<p>        Centralize retries, viewport, reporter, and baseUrl.<\/p>\n<pre><code class=\"mono\">\/\/ cypress.config.ts\r\nimport { defineConfig } from 'cypress'\r\nexport default defineConfig({\r\n  e2e: { baseUrl:'http:\/\/localhost:3000', retries:{ runMode:2, openMode:0 } },\r\n  video:true, screenshotsFolder:'cypress\/screenshots'\r\n})<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-rose\">\n<h3>25) Data Seeding<\/h3>\n<p>        Seed via backend APIs or DB tasks in <code>setupNodeEvents<\/code>. Clean between specs for isolation.<\/p>\n<pre><code class=\"mono\">\/\/ cypress\/plugins\/index.ts (setupNodeEvents)\r\non('task',{ seedDB: () =&gt; doSeed() })<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-cyan\">\n<h3>26) Test Users<\/h3>\n<p>        Create dedicated accounts\/tenants; avoid reusing prod users. Reset state via API for idempotent runs.<\/p>\n<pre><code class=\"mono\">cy.request('POST','\/test-utils\/reset-user',{ id:'u1' })<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-lime\">\n<h3>27) CI Basics<\/h3>\n<p>        Run headless in containers; cache npm; split specs across machines for speed.<\/p>\n<pre><code class=\"mono\">npx cypress run --record=false --browser chrome<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-orange\">\n<h3>28) GitHub Actions Example<\/h3>\n<p>        Minimal CI with install, build, start app, and run Cypress.<\/p>\n<pre><code class=\"mono\">- uses: actions\/checkout@v4\r\n- uses: actions\/setup-node@v4\r\n- run: npm ci\r\n- run: npm run build && npm start &amp;\r\n- run: npx wait-on http:\/\/localhost:3000\r\n- run: npx cypress run<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-indigo\">\n<h3>29) Parallelization<\/h3>\n<p>        Split spec files across CI nodes; aggregate results in reports. Keep specs similar duration.<\/p>\n<pre><code class=\"mono\"># Matrix split by spec pattern or glob shards<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-emerald\">\n<h3>30) Q&amp;A \u2014 \u201cFlaky test sources?\u201d<\/h3>\n<p>        <span class=\"q\">Answer:<\/span> Brittle selectors, fixed waits, unhandled network races, shared state, and time-dependent code. Fix with stable selectors, intercepts, and isolation.\n      <\/div>\n<p>      <!-- ===================== SECTION 4 ===================== --><\/p>\n<div class=\"section-title\">Section 4 \u2014 Components, Mocking, Accessibility &amp; Advanced<\/div>\n<div class=\"card bg-blue\">\n<h3>31) Component Testing (React)<\/h3>\n<p>        Mount components with test providers and assert render\/interaction quickly.<\/p>\n<pre><code class=\"mono\">import { mount } from 'cypress\/react18'\r\nimport { Button } from '.\/Button'\r\nit('clicks', () =&gt; {\r\n  mount(&lt;Button&gt;Save&lt;\/Button&gt;);\r\n  cy.contains('Save').click()\r\n})<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-green\">\n<h3>32) Mocking Modules<\/h3>\n<p>        For component tests, stub fetch\/axios or inject providers with mock services.<\/p>\n<pre><code class=\"mono\">cy.stub(window,'fetch').resolves(new Response('{\"ok\":true}'))<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-amber\">\n<h3>33) Accessibility (a11y)<\/h3>\n<p>        Integrate axe to catch violations in CI and during development.<\/p>\n<pre><code class=\"mono\">cy.injectAxe(); cy.checkA11y()<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-violet\">\n<h3>34) Visual Testing (Snapshot)<\/h3>\n<p>        Compare DOM snapshots or integrate percy\/visual-diff tools for pixel diffs.<\/p>\n<pre><code class=\"mono\">cy.get('#card').should('matchSnapshot')<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-rose\">\n<h3>35) Network Error Paths<\/h3>\n<p>        Stub 500\/429\/timeout to validate UX in failure modes and retries.<\/p>\n<pre><code class=\"mono\">cy.intercept('GET','\/api\/items',{ statusCode:500 })<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-cyan\">\n<h3>36) Auth Strategies<\/h3>\n<p>        Prefer API login via <code>cy.request()<\/code> to set session cookies\/localStorage, skipping slow UI steps.<\/p>\n<pre><code class=\"mono\">cy.request('POST','\/auth',{ u,p }).then(setSession)<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-lime\">\n<h3>37) Iframes &amp; Windows<\/h3>\n<p>        Access iframe body after load; stub <code>window.open<\/code> for external links.<\/p>\n<pre><code class=\"mono\">cy.get('iframe').its('0.contentDocument.body').should('not.be.empty')<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-orange\">\n<h3>38) Drag &amp; Drop<\/h3>\n<p>        Simulate pointer events or use helper plugins; assert final DOM state, not event calls.<\/p>\n<pre><code class=\"mono\">cy.get('#drag').trigger('mousedown')\r\ncy.get('#drop').trigger('mousemove').trigger('mouseup')<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-indigo\">\n<h3>39) Stubbing Dates\/Randomness<\/h3>\n<p>        Seed RNG and freeze time to avoid flake on timestamp\/UUID displays.<\/p>\n<pre><code class=\"mono\">cy.clock(1700000000000); cy.stub(Math,'random').returns(0.42)<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-emerald\">\n<h3>40) Q&amp;A \u2014 \u201cComponent vs E2E for bugs?\u201d<\/h3>\n<p>        <span class=\"q\">Answer:<\/span> Reproduce quickly in component tests for logic\/UI bugs; keep an E2E to guard the user journey. Use both for coverage.\n      <\/div>\n<p>      <!-- ===================== SECTION 5 ===================== --><\/p>\n<div class=\"section-title\">Section 5 \u2014 Performance, Reporting, Governance &amp; Interview Q&amp;A<\/div>\n<div class=\"card bg-blue\">\n<h3>41) Performance Tips<\/h3>\n<p>        Reduce network chatter with stubs, cache seeds, run component tests locally, and shard specs in CI. Keep screenshots\/videos only on failure.<\/p>\n<pre><code class=\"mono\">videoUploadOnPasses: false<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-green\">\n<h3>42) Retries &amp; Test Isolation<\/h3>\n<p>        Enable retries in <code>runMode<\/code>. Reset state in <code>beforeEach<\/code>; avoid shared globals.<\/p>\n<pre><code class=\"mono\">retries: { runMode: 2, openMode: 0 }<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-amber\">\n<h3>43) Reporting<\/h3>\n<p>        Use Mocha reporters, JUnit XML for CI, and HTML for devs. Publish artifacts from CI.<\/p>\n<pre><code class=\"mono\">npx cypress run --reporter junit --reporter-options \"mochaFile=results.xml\"<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-violet\">\n<h3>44) Coverage<\/h3>\n<p>        Instrument app with Istanbul; merge coverage from component + e2e.<\/p>\n<pre><code class=\"mono\">import '@cypress\/code-coverage\/support'<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-rose\">\n<h3>45) Linting Tests<\/h3>\n<p>        ESLint with Cypress plugin to catch anti-patterns (e.g., unawaited promises, forbidden sleeps).<\/p>\n<pre><code class=\"mono\">extends: ['plugin:cypress\/recommended']<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-cyan\">\n<h3>46) Accessibility Gate in CI<\/h3>\n<p>        Fail the build on critical a11y issues; tag violations by severity to triage.<\/p>\n<pre><code class=\"mono\">cy.checkA11y(null, { includedImpacts: ['critical'] })<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-lime\">\n<h3>47) Security &amp; PII<\/h3>\n<p>        Don\u2019t log secrets; mask tokens in screenshots; run tests in non-prod with scrubbed data.<\/p>\n<pre><code class=\"mono\">CYPRESS_RECORD_KEY from CI, not repo<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-orange tight\">\n<h3>48) Production Checklist<\/h3>\n<ul>\n<li>Stable <code>data-cy<\/code> selectors<\/li>\n<li>Intercepts for determinism<\/li>\n<li>Retries + isolation configured<\/li>\n<li>CI sharding + reports<\/li>\n<li>Coverage + a11y gates<\/li>\n<li>Test data seeding\/reset APIs<\/li>\n<\/ul><\/div>\n<div class=\"card bg-indigo\">\n<h3>49) Common Pitfalls<\/h3>\n<p>        Fixed waits, brittle selectors, test coupling, hitting prod APIs, and global state leakage. Cure with intercepts, data-cy, and cleanup.<\/p>\n<pre><code class=\"mono\">No: cy.wait(5000)\r\nYes: cy.wait('@alias')<\/code><\/pre>\n<\/p><\/div>\n<div class=\"card bg-emerald qa\">\n<h3>50) Interview Q&amp;A \u2014 20 Practical Questions (Expanded)<\/h3>\n<p><b>1) Why Cypress?<\/b> Fast feedback, auto-waits, rich dev tools, and straightforward JS API.<\/p>\n<p><b>2) E2E vs component?<\/b> E2E for journeys; component for fast, focused UI logic.<\/p>\n<p><b>3) Flake reducers?<\/b> Stable selectors, intercepts, clock control, retries.<\/p>\n<p><b>4) API login?<\/b> Use <code>cy.request()<\/code> to set session\u2014skip UI login for speed.<\/p>\n<p><b>5) When to stub?<\/b> Deterministic tests, error paths, 3rd-party outages.<\/p>\n<p><b>6) Network assertions?<\/b> Alias requests with <code>cy.intercept()<\/code> and assert status\/body.<\/p>\n<p><b>7) a11y in CI?<\/b> Integrate axe, fail on critical issues.<\/p>\n<p><b>8) Parallel strategy?<\/b> Shard by spec duration\/feature; keep specs balanced.<\/p>\n<p><b>9) Handling time?<\/b> <code>cy.clock()<\/code> + <code>cy.tick()<\/code> for timers and date UIs.<\/p>\n<p><b>10) Secrets?<\/b> Env vars via CI; never commit creds.<\/p>\n<p><b>11) Page objects?<\/b> Prefer custom commands and helpers over heavy POMs.<\/p>\n<p><b>12) Cross-browser?<\/b> Run on Chromium and Firefox; prioritize critical paths.<\/p>\n<p><b>13) Test data?<\/b> Seed\/reset via backend tasks; isolate per spec.<\/p>\n<p><b>14) Coverage merge?<\/b> Combine e2e + component; enforce thresholds.<\/p>\n<p><b>15) Visual diffs?<\/b> Add visual snapshot tool for UI regressions.<\/p>\n<p><b>16) Iframes?<\/b> Access document via <code>its('0.contentDocument')<\/code> and wrap body.<\/p>\n<p><b>17) File upload?<\/b> Use <code>selectFile<\/code> on input; assert server result.<\/p>\n<p><b>18) Accessibility roles?<\/b> Prefer role\/name selectors with Testing Library.<\/p>\n<p><b>19) Test speed?<\/b> Stub heavy calls, avoid long journeys; more component tests.<\/p>\n<p><b>20) Reporting?<\/b> JUnit\/HTML + CI artifacts; dashboard for flakes and duration trends.<\/p>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Cypress Pocket Book \u2014 Uplatz 50 deep-dive flashcards \u2022 Wide layout \u2022 Fewer scrolls \u2022 20+ Interview Q&amp;A \u2022 Readable code examples Section 1 \u2014 Fundamentals 1) What is Cypress? <span class=\"readmore\"><a href=\"https:\/\/uplatz.com\/blog\/cypress-pocket-book\/\">Read More &#8230;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":4838,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2548,2462],"tags":[],"class_list":["post-4823","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cypress","category-pocket-book"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Cypress Pocket Book | Uplatz Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/uplatz.com\/blog\/cypress-pocket-book\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Cypress Pocket Book | Uplatz Blog\" \/>\n<meta property=\"og:description\" content=\"Cypress Pocket Book \u2014 Uplatz 50 deep-dive flashcards \u2022 Wide layout \u2022 Fewer scrolls \u2022 20+ Interview Q&amp;A \u2022 Readable code examples Section 1 \u2014 Fundamentals 1) What is Cypress? Read More ...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/uplatz.com\/blog\/cypress-pocket-book\/\" \/>\n<meta property=\"og:site_name\" content=\"Uplatz Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Uplatz-1077816825610769\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-26T13:18:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-27T02:33:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/uplatz.com\/blog\/wp-content\/uploads\/2025\/08\/6.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"uplatzblog\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@uplatz_global\" \/>\n<meta name=\"twitter:site\" content=\"@uplatz_global\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"uplatzblog\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/cypress-pocket-book\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/cypress-pocket-book\\\/\"},\"author\":{\"name\":\"uplatzblog\",\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/#\\\/schema\\\/person\\\/8ecae69a21d0757bdb2f776e67d2645e\"},\"headline\":\"Cypress Pocket Book\",\"datePublished\":\"2025-08-26T13:18:07+00:00\",\"dateModified\":\"2025-08-27T02:33:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/cypress-pocket-book\\\/\"},\"wordCount\":1053,\"publisher\":{\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/cypress-pocket-book\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/08\\\/6.png\",\"articleSection\":[\"Cypress\",\"Pocket Book\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/cypress-pocket-book\\\/\",\"url\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/cypress-pocket-book\\\/\",\"name\":\"Cypress Pocket Book | Uplatz Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/cypress-pocket-book\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/cypress-pocket-book\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/08\\\/6.png\",\"datePublished\":\"2025-08-26T13:18:07+00:00\",\"dateModified\":\"2025-08-27T02:33:17+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/cypress-pocket-book\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/uplatz.com\\\/blog\\\/cypress-pocket-book\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/cypress-pocket-book\\\/#primaryimage\",\"url\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/08\\\/6.png\",\"contentUrl\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/wp-content\\\/uploads\\\/2025\\\/08\\\/6.png\",\"width\":1280,\"height\":720,\"caption\":\"Cypress Pocket Book\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/cypress-pocket-book\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Cypress Pocket Book\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/\",\"name\":\"Uplatz Blog\",\"description\":\"Uplatz is a global IT Training &amp; Consulting company\",\"publisher\":{\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/#organization\",\"name\":\"uplatz.com\",\"url\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/11\\\/Uplatz-Logo-Copy-2.png\",\"contentUrl\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/wp-content\\\/uploads\\\/2016\\\/11\\\/Uplatz-Logo-Copy-2.png\",\"width\":1280,\"height\":800,\"caption\":\"uplatz.com\"},\"image\":{\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/Uplatz-1077816825610769\\\/\",\"https:\\\/\\\/x.com\\\/uplatz_global\",\"https:\\\/\\\/www.instagram.com\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/7956715?trk=tyah&amp;amp;amp;amp;trkInfo=clickedVertical:company,clickedEntityId:7956715,idx:1-1-1,tarId:1464353969447,tas:uplatz\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/uplatz.com\\\/blog\\\/#\\\/schema\\\/person\\\/8ecae69a21d0757bdb2f776e67d2645e\",\"name\":\"uplatzblog\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7f814c72279199f59ded4418a8653ad15f5f8904ac75e025a4e2abe24d58fa5d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7f814c72279199f59ded4418a8653ad15f5f8904ac75e025a4e2abe24d58fa5d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/7f814c72279199f59ded4418a8653ad15f5f8904ac75e025a4e2abe24d58fa5d?s=96&d=mm&r=g\",\"caption\":\"uplatzblog\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Cypress Pocket Book | Uplatz Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/uplatz.com\/blog\/cypress-pocket-book\/","og_locale":"en_US","og_type":"article","og_title":"Cypress Pocket Book | Uplatz Blog","og_description":"Cypress Pocket Book \u2014 Uplatz 50 deep-dive flashcards \u2022 Wide layout \u2022 Fewer scrolls \u2022 20+ Interview Q&amp;A \u2022 Readable code examples Section 1 \u2014 Fundamentals 1) What is Cypress? Read More ...","og_url":"https:\/\/uplatz.com\/blog\/cypress-pocket-book\/","og_site_name":"Uplatz Blog","article_publisher":"https:\/\/www.facebook.com\/Uplatz-1077816825610769\/","article_published_time":"2025-08-26T13:18:07+00:00","article_modified_time":"2025-08-27T02:33:17+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/uplatz.com\/blog\/wp-content\/uploads\/2025\/08\/6.png","type":"image\/png"}],"author":"uplatzblog","twitter_card":"summary_large_image","twitter_creator":"@uplatz_global","twitter_site":"@uplatz_global","twitter_misc":{"Written by":"uplatzblog","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/uplatz.com\/blog\/cypress-pocket-book\/#article","isPartOf":{"@id":"https:\/\/uplatz.com\/blog\/cypress-pocket-book\/"},"author":{"name":"uplatzblog","@id":"https:\/\/uplatz.com\/blog\/#\/schema\/person\/8ecae69a21d0757bdb2f776e67d2645e"},"headline":"Cypress Pocket Book","datePublished":"2025-08-26T13:18:07+00:00","dateModified":"2025-08-27T02:33:17+00:00","mainEntityOfPage":{"@id":"https:\/\/uplatz.com\/blog\/cypress-pocket-book\/"},"wordCount":1053,"publisher":{"@id":"https:\/\/uplatz.com\/blog\/#organization"},"image":{"@id":"https:\/\/uplatz.com\/blog\/cypress-pocket-book\/#primaryimage"},"thumbnailUrl":"https:\/\/uplatz.com\/blog\/wp-content\/uploads\/2025\/08\/6.png","articleSection":["Cypress","Pocket Book"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/uplatz.com\/blog\/cypress-pocket-book\/","url":"https:\/\/uplatz.com\/blog\/cypress-pocket-book\/","name":"Cypress Pocket Book | Uplatz Blog","isPartOf":{"@id":"https:\/\/uplatz.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/uplatz.com\/blog\/cypress-pocket-book\/#primaryimage"},"image":{"@id":"https:\/\/uplatz.com\/blog\/cypress-pocket-book\/#primaryimage"},"thumbnailUrl":"https:\/\/uplatz.com\/blog\/wp-content\/uploads\/2025\/08\/6.png","datePublished":"2025-08-26T13:18:07+00:00","dateModified":"2025-08-27T02:33:17+00:00","breadcrumb":{"@id":"https:\/\/uplatz.com\/blog\/cypress-pocket-book\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/uplatz.com\/blog\/cypress-pocket-book\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/uplatz.com\/blog\/cypress-pocket-book\/#primaryimage","url":"https:\/\/uplatz.com\/blog\/wp-content\/uploads\/2025\/08\/6.png","contentUrl":"https:\/\/uplatz.com\/blog\/wp-content\/uploads\/2025\/08\/6.png","width":1280,"height":720,"caption":"Cypress Pocket Book"},{"@type":"BreadcrumbList","@id":"https:\/\/uplatz.com\/blog\/cypress-pocket-book\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/uplatz.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Cypress Pocket Book"}]},{"@type":"WebSite","@id":"https:\/\/uplatz.com\/blog\/#website","url":"https:\/\/uplatz.com\/blog\/","name":"Uplatz Blog","description":"Uplatz is a global IT Training &amp; Consulting company","publisher":{"@id":"https:\/\/uplatz.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/uplatz.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/uplatz.com\/blog\/#organization","name":"uplatz.com","url":"https:\/\/uplatz.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/uplatz.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/uplatz.com\/blog\/wp-content\/uploads\/2016\/11\/Uplatz-Logo-Copy-2.png","contentUrl":"https:\/\/uplatz.com\/blog\/wp-content\/uploads\/2016\/11\/Uplatz-Logo-Copy-2.png","width":1280,"height":800,"caption":"uplatz.com"},"image":{"@id":"https:\/\/uplatz.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Uplatz-1077816825610769\/","https:\/\/x.com\/uplatz_global","https:\/\/www.instagram.com\/","https:\/\/www.linkedin.com\/company\/7956715?trk=tyah&amp;amp;amp;amp;trkInfo=clickedVertical:company,clickedEntityId:7956715,idx:1-1-1,tarId:1464353969447,tas:uplatz"]},{"@type":"Person","@id":"https:\/\/uplatz.com\/blog\/#\/schema\/person\/8ecae69a21d0757bdb2f776e67d2645e","name":"uplatzblog","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/7f814c72279199f59ded4418a8653ad15f5f8904ac75e025a4e2abe24d58fa5d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/7f814c72279199f59ded4418a8653ad15f5f8904ac75e025a4e2abe24d58fa5d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7f814c72279199f59ded4418a8653ad15f5f8904ac75e025a4e2abe24d58fa5d?s=96&d=mm&r=g","caption":"uplatzblog"}}]}},"_links":{"self":[{"href":"https:\/\/uplatz.com\/blog\/wp-json\/wp\/v2\/posts\/4823","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/uplatz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/uplatz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/uplatz.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/uplatz.com\/blog\/wp-json\/wp\/v2\/comments?post=4823"}],"version-history":[{"count":2,"href":"https:\/\/uplatz.com\/blog\/wp-json\/wp\/v2\/posts\/4823\/revisions"}],"predecessor-version":[{"id":4863,"href":"https:\/\/uplatz.com\/blog\/wp-json\/wp\/v2\/posts\/4823\/revisions\/4863"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/uplatz.com\/blog\/wp-json\/wp\/v2\/media\/4838"}],"wp:attachment":[{"href":"https:\/\/uplatz.com\/blog\/wp-json\/wp\/v2\/media?parent=4823"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/uplatz.com\/blog\/wp-json\/wp\/v2\/categories?post=4823"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/uplatz.com\/blog\/wp-json\/wp\/v2\/tags?post=4823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}