Resource library

QA Interview

Cypress Take Home Assignment Examples (2026)

Study cypress take home assignment examples with runnable TypeScript tests, scoring criteria, review questions, and submission tactics for 2026 QA interviews.

25 min read | 3,675 words

TL;DR

The strongest Cypress take-home submission is deliberately small, reproducible, risk-based, and easy to review. It combines runnable tests with explicit assumptions, useful failure evidence, and an honest account of remaining coverage.

Key Takeaways

  • Translate an ambiguous brief into explicit assumptions, prioritized risks, and a small executable scope.
  • Submit a clean TypeScript project that runs from one documented command on a fresh checkout.
  • Assert business outcomes, network contracts, error behavior, and accessibility instead of counting clicks.
  • Use stable selectors, isolated data, observable waits, and focused diagnostics to prevent flaky evidence.
  • Explain what stubs prove, what they cannot prove, and which integrated checks you would add next.
  • Make the README, CI artifacts, and walkthrough as reviewable as the test code itself.

Cypress take home assignment examples should teach you how to turn a short product brief into trustworthy test evidence. A strong submission does not win by having the most files; it wins by selecting important risks, using Cypress correctly, running cleanly from one command, and explaining what the chosen test boundary proves.

Use this guide as a practice interview hub. You will examine planning, runnable TypeScript, selectors, network behavior, authentication, accessibility, CI, review criteria, and presentation through 48 distinct questions. For a broader foundation before attempting the exercise, read the Cypress framework guide.

TL;DR

Assignment area Minimum credible evidence Stronger signal
Scope Assumptions and three prioritized scenarios Risk ranking plus named omissions
Automation One-command local run Clean checkout and CI proof
UI Stable locators and visible outcomes Keyboard, error, and empty states
Network Request and response assertions Clear split between spy, stub, and real service
Reliability Independent tests and no fixed sleeps Unique data, retries tracked, useful artifacts
Communication Setup steps and result summary Trade-offs, defect report, and extension plan

Aim for a submission that a reviewer can clone, install, and assess in ten minutes. Complete the highest-risk workflow first, then add negative, accessibility, and integration evidence only while time remains.

1. How to Approach Cypress Take Home Assignment Examples

Q: What should you do during the first 20 minutes?

Read the brief once for the requested deliverables and again for actors, state changes, constraints, and evaluation clues. Convert unknowns into a short assumption list, then rank candidate scenarios by impact and likelihood. Do not open a spec file until you can state which failure your first test is meant to expose.

Q: How should you handle an incomplete requirement?

Choose the narrowest reversible interpretation and record it in the README beside its testing consequence. If a task title limit is unspecified, for example, explain the illustrative boundary you used rather than presenting it as a product fact. Flag assumptions that would change the oracle so the reviewer can judge your reasoning separately from their hidden implementation.

Q: What fits in a two-hour Cypress take home test?

Reserve about 15 minutes for discovery, 70 for a critical path and two meaningful risks, 20 for cleanup and diagnostics, and 15 for a fresh run. Prefer one creation journey, one server rejection, and one resilience or accessibility case over a broad unfinished suite. List performance, full browser coverage, and exhaustive combinations as follow-up work with priorities.

Q: What deliverables make the assignment easy to review?

A useful Cypress test project example provides source tests, configuration, deterministic fixtures, a concise README, and the exact command that produced the final result. Include a coverage note linking each scenario to a risk and a limitations section that names any stubs or unavailable services. Generated videos, screenshots, or reports belong in CI artifacts or an ignored output directory, not in a noisy repository commit.

Q: Which clarification questions are worth sending?

For a Cypress interview practical task, ask whether the target environment may be mutated, which browsers matter, how authentication is supplied, and whether external APIs can be stubbed. Confirm the time box and whether reviewers expect code only, a test plan, or both. Avoid questions already answered by package scripts or product copy because that suggests incomplete discovery.

2. Turn a QA Automation Take Home Exercise Into Risk-Based Coverage

Q: How do you prioritize a checkout assignment?

Put money loss, duplicate orders, authorization, inventory, and misleading confirmation ahead of styling details. Trace each risk to an observable checkpoint such as one POST, one order identifier, and the correct charged total. Add coupon formatting variants only after the core transaction and failure recovery are protected.

Q: What belongs in a compact coverage matrix?

Use columns for risk, precondition, action, expected outcome, test layer, and automation status. A row for duplicate submission might require one cart, a double click, one network mutation, and one final order. Five discriminating rows communicate more judgment than 40 generic test-case titles.

Q: How many happy paths should you automate?

Automate one representative path per distinct business outcome, not one per cosmetic data variation. Parameterize only inputs that exercise the same decision and produce equally diagnosable failures. When guest and signed-in checkout use different pricing or ownership rules, treat them as separate paths rather than table rows.

Q: Which negative case has the highest value?

Select the rejection most likely to leave incorrect state or confuse the customer. A failed save that still creates a record is usually more serious than a missing optional tooltip, so assert both the error and absence of the side effect. Explain that choice using domain impact instead of calling every edge case critical.

Q: Should accessibility be part of a short assignment?

Yes, but target the interaction under test rather than claiming a complete audit. Verify label association, keyboard operation, focus movement, alert semantics, and accessible names for the chosen journey. These checks expose functional barriers and show that your oracle extends beyond visible text.

3. Build a Runnable Cypress TypeScript Baseline

Q: What project shape is sufficient for a Cypress TypeScript assignment?

Keep configuration at the root, place browser specs under cypress/e2e, and isolate only reusable data or commands that earn their abstraction. The following package runs a tiny task application and Cypress together, giving reviewers one reproducible entry point. Pin the installed dependency graph with package-lock.json in the actual submission.

{
  "scripts": {
    "start": "node assignment-app.mjs",
    "cy:run": "cypress run",
    "test:e2e": "start-server-and-test start http://127.0.0.1:4173 cy:run"
  },
  "devDependencies": {
    "cypress": "^15.20.0",
    "start-server-and-test": "^2.1.2",
    "typescript": "^5.9.3"
  }
}

Run npm install, then verify dependency resolution with npx cypress version. The command should print installed Cypress package and binary versions without opening the runner.

Q: How can you provide a self-contained practice application?

Use a local fixture service whose behavior is explicit and safe to reset. This Node server renders one form, persists tasks in memory, rejects titles shorter than three characters, and exposes a test-only reset route. It gives the later specs a real browser-to-server boundary without relying on an unstable public demo.

// assignment-app.mjs
import { createServer } from 'node:http';

const tasks = [];
const page = `<!doctype html>
<html lang="en"><head><meta charset="utf-8"><title>Task Board</title></head>
<body><main><h1>Task Board</h1>
<form><label for="title">Task title</label><input id="title" data-cy="task-title">
<button type="submit">Add task</button></form><p role="alert" hidden></p><ul data-cy="task-list"></ul></main>
<script>
const form = document.querySelector('form');
const input = document.querySelector('#title');
const alertBox = document.querySelector('[role=alert]');
const list = document.querySelector('[data-cy=task-list]');
form.addEventListener('submit', async (event) => {
  event.preventDefault(); alertBox.hidden = true;
  try {
    const response = await fetch('/api/tasks', {
      method: 'POST', headers: { 'content-type': 'application/json' },
      body: JSON.stringify({ title: input.value })
    });
    const body = await response.json();
    if (!response.ok) throw new Error(body.error);
    const item = document.createElement('li');
    item.dataset.cy = 'task-item'; item.textContent = body.title; list.append(item); input.value = '';
  } catch { alertBox.textContent = 'Network unavailable'; alertBox.hidden = false; }
});
</script></body></html>`;

const sendJson = (response, status, body) => {
  response.writeHead(status, { 'content-type': 'application/json' });
  response.end(JSON.stringify(body));
};

createServer(async (request, response) => {
  if (request.method === 'GET' && request.url === '/') {
    response.writeHead(200, { 'content-type': 'text/html; charset=utf-8' }); return response.end(page);
  }
  if (request.method === 'POST' && request.url === '/api/reset') {
    tasks.length = 0; response.writeHead(204); return response.end();
  }
  if (request.method === 'POST' && request.url === '/api/tasks') {
    let raw = ''; for await (const chunk of request) raw += chunk;
    const title = String(JSON.parse(raw).title || '').trim();
    if (title.length < 3) return sendJson(response, 422, { error: 'Use at least 3 characters' });
    const task = { id: tasks.length + 1, title }; tasks.push(task); return sendJson(response, 201, task);
  }
  sendJson(response, 404, { error: 'Not found' });
}).listen(4173, '127.0.0.1', () => console.log('Task Board on http://127.0.0.1:4173'));

Start it with node assignment-app.mjs and verify it in another terminal with curl -i http://127.0.0.1:4173/. Expect HTTP/1.1 200 OK and an HTML page containing Task Board.

Q: What should the Cypress configuration contain?

Set the base URL, spec pattern, isolation policy, and run-mode retries explicitly so the test contract is visible. Avoid copying every default into the file because that hides the few choices a reviewer needs to inspect. This configuration keeps retries off locally and allows one diagnostic retry in CI.

// cypress.config.ts
import { defineConfig } from 'cypress';

export default defineConfig({
  e2e: {
    baseUrl: 'http://127.0.0.1:4173',
    specPattern: 'cypress/e2e/**/*.cy.ts',
    testIsolation: true,
    retries: { openMode: 0, runMode: 1 },
  },
});

Verify the configuration with npx cypress run --config-file cypress.config.ts --spec cypress/e2e/task-board.cy.ts after adding the next block. A wrong URL should fail at cy.visit('/'), which proves the base URL is actually in use.

Q: What does a credible first spec assert?

Check the outgoing contract, response status, returned business value, and rendered outcome in one focused creation scenario. Add separate tests for server validation and transport failure so each failure points to one behavior. The intercept is registered before the triggering click, and the reset API removes order dependence.

// cypress/e2e/task-board.cy.ts
describe('Task Board assignment', () => {
  beforeEach(() => {
    cy.request('POST', '/api/reset');
    cy.visit('/');
  });

  it('creates a task from a valid title', () => {
    cy.intercept('POST', '/api/tasks').as('createTask');
    cy.get('[data-cy="task-title"]').type('Review checkout');
    cy.contains('button', 'Add task').click();
    cy.wait('@createTask').then(({ request, response }) => {
      expect(request.body).to.deep.equal({ title: 'Review checkout' });
      expect(response?.statusCode).to.equal(201);
      expect(response?.body.title).to.equal('Review checkout');
    });
    cy.contains('[data-cy="task-item"]', 'Review checkout').should('be.visible');
  });

  it('shows a server validation message', () => {
    cy.get('[data-cy="task-title"]').type('x');
    cy.contains('button', 'Add task').click();
    cy.get('[role="alert"]').should('be.visible').and('have.text', 'Use at least 3 characters');
    cy.get('[data-cy="task-item"]').should('not.exist');
  });

  it('reports an unavailable network', () => {
    cy.intercept('POST', '/api/tasks', { forceNetworkError: true }).as('failedCreate');
    cy.get('[data-cy="task-title"]').type('Recover failure');
    cy.contains('button', 'Add task').click();
    cy.wait('@failedCreate');
    cy.get('[role="alert"]').should('be.visible').and('have.text', 'Network unavailable');
  });
});

Run npm run test:e2e. Expect three passing tests, including a deterministic Network unavailable message for the forced transport failure.

Q: Should you add custom commands immediately?

No, three readable native interactions do not justify a global abstraction. Extract a command when several specs share a stable domain action and the helper preserves useful logging, types, and failure location. A page object that merely renames get, type, and click adds navigation cost without reducing change risk.

4. Selectors, Synchronization, and UI Assertions

Q: How should you choose selectors?

Start with labels, roles, button names, and other user-facing semantics when they are stable and unambiguous. Add data-cy for controls or containers whose text changes independently of behavior. The Cypress data-cy selector guide shows how to keep test hooks separate from styling classes.

Q: Why is cy.wait(2000) weak evidence?

Elapsed time does not prove that the application reached the required state. Wait on an aliased request, a route change, an enabled control, or a retryable assertion tied to the behavior. A fixed delay can be both too long on a fast machine and too short under CI load.

Q: What should a UI assertion prove after a save?

Assert the customer-visible record, its normalized values, and any state transition that matters, such as the form clearing or submit button re-enabling. Avoid asserting ten incidental DOM properties that do not affect the feature contract. If persistence is important, reload or query a supported API instead of trusting an optimistic toast.

Q: How do you test a loading state without creating a race?

Delay a controlled intercepted response, trigger the request, and assert the spinner or disabled control before releasing or awaiting the response. Then confirm the loading indicator disappears and the final content replaces it. Keep this as a UI-state test because a fully real fast service may complete before the intermediate state becomes observable.

Q: When is { force: true } defensible?

Use it only when the product intentionally hides a native control behind an accessible proxy, such as a file input activated by a labeled button. For ordinary clicks, forcing bypasses Cypress actionability checks and may let an impossible user action pass. Document the DOM reason so the option does not become a routine escape hatch.

5. Network and API Decisions

Q: What is the difference between spying and stubbing with cy.intercept()?

A spy observes application traffic while the real destination responds; a stub supplies a controlled response at the Cypress proxy. Use spying to prove integration and stubbing to force rare UI states or deterministic boundaries. The cy.intercept example guide covers matching, aliases, and response inspection in more depth.

Q: What should you inspect on an intercepted request?

Assert the method, stable URL parts, meaningful headers, and payload fields the feature is responsible for producing. On the response, check status and the business values consumed by the page rather than snapshotting an entire volatile object. Redact authorization headers and personal data from screenshots or custom logs.

Q: When should setup use cy.request()?

Use it to create or reset preconditions faster than the UI when the assignment permits a test API. Keep one browser test for the user-facing creation flow if that flow itself carries risk. Remember that cy.request() originates outside the page, so cy.intercept() does not observe it as browser traffic.

Q: How do you test a 500 response responsibly?

Stub one matching request with a stable error body and assert recovery controls, preserved input, and the absence of false success. Do not call an undocumented endpoint or damage shared data merely to provoke a server fault. State plainly that the test proves frontend handling, not production backend resilience.

Q: How can over-mocking weaken the submission?

If every response is fabricated, the suite cannot detect broken routing, cookies, serialization, deployment, or service compatibility. Keep controlled tests for hard-to-create branches, then retain at least one integrated critical journey. Label the boundary of each scenario so reviewers never mistake simulated evidence for end-to-end proof.

6. Authentication, Data, and Test Isolation

Q: How should login be handled across several specs?

Use cy.session() around a programmatic or UI login when recreating valid browser state is expensive. Build the session key from identity and role, then validate restored state with an authenticated endpoint or protected page. The cy.session example explains cache identity and validation behavior.

Q: Must the assignment test the login UI?

Only if authentication is part of the stated risk or deliverable. One focused login test can protect the form, while feature specs authenticate through a faster supported path. This split preserves coverage without paying the same UI setup cost in every test.

Q: What makes test data parallel-safe?

Give each scenario a unique suffix derived from the run and test, and let it own every record it mutates. Cleanup must target recorded identifiers, never broad delete queries against shared environments. Fixed usernames and globally reused carts create collisions that spec splitting cannot solve.

Q: Should tests depend on earlier tests?

No, each case should establish its own preconditions and remain valid when run alone or in another order. Shared setup may create immutable reference data, but one test must not produce a record that a later test expects. Verify independence with Cypress's single-spec and title-filtered runs before submission.

Q: How do you protect secrets in a take-home repository?

Read credentials from environment configuration and commit only documented placeholders. Never place production tokens, personal accounts, or service-role keys in fixtures, screenshots, videos, or example logs. If access was supplied privately, explain the variable names and fail fast with a safe missing-value message.

7. Negative, Accessibility, File, and Browser Cases

Q: Which input boundaries should you cover?

Choose values immediately below, at, and above documented limits, plus empty, whitespace-only, and structurally invalid partitions where relevant. Include Unicode or normalization only when names, search, or identifiers make it risky. Tie each value to a distinct validation rule so the suite does not become a random string collection.

Q: How do you verify an error state well?

Assert specific user guidance, semantic exposure through role=alert or linked error text, focus behavior, and absence of a forbidden side effect. Preserve entered data when retry is expected and verify that duplicate submissions stay blocked. Error color alone is not an adequate oracle for either meaning or accessibility.

Q: What keyboard check adds useful coverage?

Start at a known focus point, navigate through controls in logical order, and activate the primary action without a mouse. Confirm the focus indicator remains visible and any modal traps and restores focus correctly. Do not automate arbitrary Tab counts across the whole page because small unrelated layout changes make that brittle.

Q: How should file upload be tested?

Call selectFile() on the HTML file input using a committed safe fixture or an in-memory Cypress.Buffer, then assert server acknowledgement and the visible filename or preview. Cover one invalid type or size boundary separately. See the Cypress file upload guide for select and drag-drop modes.

Q: How much cross-browser evidence is enough?

Run the prioritized path in every browser the brief names, and state the exact browser family used rather than claiming universal coverage. Add browser-specific cases only when the product relies on risky APIs, downloads, permissions, or layout behavior. A green Chromium run does not support a Safari compatibility claim.

8. CI, Debugging, and Flake Control

Q: What should the CI job prove?

It should install from the lockfile, start the application, execute the same documented test command, and retain useful failure artifacts. Keep the workflow small enough that a reviewer can map it to local execution. This job reuses the earlier test:e2e script and uploads screenshots only when a failure occurs.

name: Cypress assignment
on: [push]
jobs:
  e2e:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
          cache: npm
      - run: npm ci
      - run: npm run test:e2e
      - if: failure()
        uses: actions/upload-artifact@v4
        with:
          name: cypress-screenshots
          path: cypress/screenshots
          if-no-files-found: ignore

Verify locally with npm ci && npm run test:e2e, then confirm the hosted job reports the same three specs as passing. Deliberately break one assertion on a branch to ensure the artifact step captures a screenshot before calling the workflow complete.

Q: A test passes locally but fails in CI. What comes first?

Compare Node, Cypress, browser, viewport, environment variables, application build, and test data before editing timeouts. Read the earliest meaningful failure with its command log, screenshot, console, and network evidence. Reproduce the headless command locally so each hypothesis can be tested against the same execution path.

Q: When are retries acceptable?

A small run-mode retry can gather evidence while an intermittent issue has an owner and deadline. Track attempts because a passing retry still signals instability. Never use retries to excuse shared state, late intercept registration, generated selectors, or an application request that sometimes never fires.

Q: How do you diagnose an intercept timeout?

Confirm registration happened before the trigger, then compare the actual method, hostname, path, and query string with the matcher. Check whether browser caching or an earlier failure prevented any network request. The Cypress flaky test guide offers a systematic path from symptom to cause.

Q: Which artifacts are worth retaining?

Keep the failed screenshot, command output, relevant browser console lines, and network or server logs tied to the run identifier. Video is useful when motion or ordering matters, but it can be expensive and may expose data. Set a short retention period and sanitize artifacts before sharing them outside the hiring loop.

9. README, Code Review, and Architecture Choices

Q: What belongs in the README?

State prerequisites, installation, one-command execution, browser options, assumptions, coverage, known limitations, and troubleshooting. Add a short architecture note explaining data setup, selectors, stubs, and cleanup. A reviewer should not need to inspect package scripts to discover how to run the work.

Q: What will an interviewer notice in code review?

Reviewers look for tests that protect named risks, fail for the right reason, and expose enough context to diagnose the fault. They also inspect isolation, secret handling, locator stability, network boundaries, and unnecessary abstraction. Clean formatting cannot rescue a suite whose assertions pass while the business outcome is broken.

Q: Are page objects expected?

Use them only when they centralize durable domain vocabulary or isolate a genuine source of change. Small functions, app actions, or direct commands are often clearer in a compact Cypress exercise. Explain the cost of whichever pattern you choose instead of presenting it as a universal framework rule.

Q: How should you describe missing coverage?

Name the omitted risk, why it was deferred, and the next test layer or scenario that would address it. For example, note that a stubbed decline covers UI recovery but still needs a sandbox provider contract test. Honest boundaries demonstrate prioritization; vague claims of complete coverage undermine trust.

10. Present Cypress Take Home Assignment Examples Like a Senior

Q: How should you structure the walkthrough?

Open with the product risk and time box, then show the coverage map before code. Run the suite, inspect one meaningful test, and demonstrate how a forced failure appears in the artifacts. Close with trade-offs and the first three extensions you would make with another day.

Q: What if a reviewer challenges your design?

Restate the constraint behind your choice and invite a concrete alternative to compare. Evaluate both options against confidence, maintenance, runtime, and diagnostic quality rather than defending personal preference. If the new information changes the best answer, say so and update the recommendation.

Q: How should defects be reported from the assignment?

Write the user impact, environment, minimal reproduction, expected and actual behavior, and attached evidence. Separate confirmed observation from suspected cause, especially when only browser access is available. Include data identifiers safe for the reviewer to inspect and remove any customer information.

Q: What practice routine improves take-home performance?

For a realistic Cypress automation coding assignment, choose a small feature, set a two-hour timer, and finish with a clean-checkout run plus a ten-minute spoken review. On the next attempt, keep the same feature but change one constraint such as authentication, server failure, or parallel data. Rehearse in the QA interview practice workspace, then upload your resume to align examples with the level you claim.

How Interviewers Grade Your Answers

Interviewers usually separate correctness from judgment. Correctness covers real Cypress APIs, compiling TypeScript, accurate assertions, and repeatable execution; judgment covers risk selection, boundaries, security, diagnosis, and clear communication.

Dimension Weak evidence Strong evidence
Problem framing Starts coding from assumptions Names actor, outcome, risks, and constraints
Test design Automates many shallow paths Selects distinct scenarios with defensible oracles
Cypress use Sleeps and brittle selectors Retryable conditions, stable locators, clear aliases
Reliability Depends on order and shared users Isolated data, clean reruns, actionable artifacts
Architecture Adds patterns by habit Explains abstraction and boundary trade-offs
Communication Claims complete coverage Documents omissions and next priorities

These Cypress assignment evaluation criteria reward a candidate who can explain why every test exists and what regression would make it fail. For additional architecture vocabulary, use the modern Cypress test architecture guide, then score your own submission from one to five in each dimension.

Interview Questions and Answers

The 48 questions above cover the practical interview from scoping through presentation. The interviewQnA field below also supplies 12 concise prompts for rapid rehearsal.

Common Mistakes

  • Coding before identifying the actor, outcome, environment, and highest-risk failure.
  • Submitting a repository that requires undocumented global tools or manual startup steps.
  • Checking only visibility while ignoring the request, persisted state, or forbidden side effect.
  • Registering cy.intercept() after the application already sent the matching request.
  • Using fixed sleeps as a replacement for an observable readiness condition.
  • Selecting generated classes, DOM positions, or copy unrelated to the behavior.
  • Making one long scenario responsible for creation, editing, deletion, logout, and reporting.
  • Reusing mutable accounts or records that collide during parallel execution.
  • Treating stubs as proof that the deployed backend and browser integration work.
  • Forcing clicks to bypass genuine overlay, disabled-state, or focus defects.
  • Hiding tokens in committed fixtures, screenshots, videos, or console output.
  • Adding custom commands and page objects before repeated change patterns exist.
  • Increasing global timeouts or retries before classifying the failure source.
  • Claiming complete accessibility or cross-browser coverage from one narrow check.
  • Omitting a clean install and final headless run because the interactive runner passed.
  • Presenting trade-offs as tool doctrine rather than decisions tied to the assignment.

Conclusion

The best cypress take home assignment examples reveal a repeatable engineering process: clarify the brief, prioritize risk, build one runnable proof, inspect failure evidence, and document the boundary. Cypress knowledge matters, but reviewers also need to see product reasoning, data safety, diagnosis, and restraint.

Run the task-board exercise from a fresh directory, break each scenario once, and study the resulting output. Then replace the sample behavior with the employer's real domain while keeping the same discipline around scope, verification, and honest evidence.

Interview Questions and Answers

How do you scope a Cypress take-home assignment?

I identify the user outcome, highest-impact failures, environment constraints, and time box before coding. I automate one critical path plus distinct negative and resilience risks, then document deferred coverage with priorities. That scope makes the submission achievable and the trade-offs visible.

What makes a Cypress test trustworthy?

A trustworthy test controls its preconditions, performs a realistic action, and asserts the business outcome and important side effects. It can run independently, fails for a specific reason, and leaves useful evidence. A clean rerun from a fresh checkout confirms that the result is reproducible.

When do you use cy.intercept in an assignment?

I use `cy.intercept()` to observe browser traffic or control a response needed for a focused UI state. I register it before the trigger, match the narrow method and route, and explain whether the scenario is integrated or stubbed. Request and response assertions stay limited to fields owned by the feature.

What is the difference between cy.request and cy.intercept?

`cy.request()` sends a request from Cypress and is useful for setup or direct API checks. `cy.intercept()` observes or modifies traffic initiated by the browser application, so it cannot spy on a `cy.request()` call. I choose the command according to the boundary the scenario must prove.

How do you choose Cypress selectors?

I prefer stable accessible semantics when they uniquely describe the control. I add `data-cy` hooks when text or structure changes independently of behavior, and I avoid generated classes or positional paths. The selector should survive harmless styling and layout refactors.

How do you remove fixed waits from Cypress tests?

I identify the observable condition that represents readiness, such as an aliased response, enabled button, changed route, or visible status. Cypress can retry the related query and assertion instead of guessing a delay. This produces faster passing runs and more meaningful timeouts.

When would you use cy.session?

I use `cy.session()` when feature specs need the same valid browser session and repeated login is costly. The cache key contains the identity and role, while a validation callback confirms that restored state remains authorized. A separate scenario still protects the login UI when it is in scope.

How do you make Cypress tests parallel-safe?

Each test owns unique records and establishes its own preconditions. Cleanup uses captured identifiers, and neither spec order nor globally shared accounts determine the outcome. I verify isolation by running individual tests and distributing specs across workers.

How do you investigate a CI-only Cypress failure?

I compare runtime, browser, viewport, build, configuration, and data with the local run. Then I inspect the earliest useful error and reproduce the exact headless command before changing synchronization or timeouts. One diagnostic experiment at a time keeps the investigation evidence-led.

Are retries a valid fix for flaky tests?

Retries can collect evidence and reduce temporary disruption while a known intermittent failure is being repaired. They are not a fix for shared state, weak selectors, incorrect request matching, or missing readiness conditions. I track retried passes so the team does not mistake them for clean reliability.

What should you say about mocked responses?

I state that a mock provides deterministic evidence for frontend behavior at a controlled boundary. I also identify the routing, authentication, serialization, and live service compatibility that it does not prove. At least one integrated critical path should remain when the environment permits it.

How do you present a Cypress assignment to reviewers?

I begin with risk and scope, show the coverage map, run the suite, and inspect one representative failure. I finish with architectural trade-offs, known limitations, and the next tests I would add. The walkthrough should let reviewers connect every implementation choice to release confidence.

Frequently Asked Questions

What is usually included in a Cypress take-home assignment?

A typical exercise asks you to automate a small user journey, add negative coverage, and explain your design. Reviewers may also expect setup instructions, CI configuration, assumptions, and a short test strategy.

How many Cypress tests should I submit?

There is no ideal count. For a short exercise, three to six distinct scenarios with strong assertions and clean execution are often more persuasive than a large repetitive suite.

Should a Cypress assignment use TypeScript?

Use TypeScript when the brief or existing repository supports it. Type request bodies, fixtures, helpers, and domain results where doing so prevents realistic mistakes, but do not add complex generics only to impress reviewers.

Can I use page objects in a Cypress take-home test?

Yes, if they isolate real change or provide clear domain language. Direct Cypress commands or small functions are better when a page object would only wrap selectors and clicks.

Should I stub APIs in the assignment?

Stub rare failures and deterministic UI states, but preserve an integrated path when the environment allows it. Label each stub clearly and state that it proves frontend behavior rather than live backend compatibility.

How do I avoid flaky Cypress assignment tests?

Use independent data, stable selectors, aliases or retryable assertions, and deterministic setup. Remove fixed sleeps, execution-order dependencies, and shared mutable accounts before increasing retries.

What should the assignment README contain?

Document prerequisites, installation, exact run commands, browser choices, assumptions, automated coverage, limitations, and troubleshooting. Include enough architecture context for a reviewer to understand test data, stubs, selectors, and cleanup.

How long should I spend polishing a take-home assignment?

Honor the stated time box and report it honestly. Reserve the final 20 to 30 minutes for a clean install, headless run, README review, secret scan, and removal of distracting generated output.

Related Guides