---
title: 'Knowledge check | Cypress Tutorial: First Spec to CI'
description: Nine questions on the decisions that matter most in a real Cypress suite.
  Each answer comes with a short explanation, so a wrong answer points you back to…
source_url:
  html: https://testingbot.com/resources/courses/cypress/knowledge-check
  md: https://testingbot.com/resources/courses/cypress/knowledge-check.md
---

Course

[Cypress Tutorial: First Spec to CI](https://testingbot.com/resources/courses/cypress)

Chapter 11 of 11

1. [1 Cypress Tutorial for Beginners](https://testingbot.com/resources/courses/cypress)
2. [2 Install Cypress and Run a First Spec](https://testingbot.com/resources/courses/cypress/install-and-first-spec)
3. [3 Selectors and the Cypress Command Queue](https://testingbot.com/resources/courses/cypress/selectors-and-the-command-queue)
4. [4 Cypress Assertions and Waiting Without Sleeps](https://testingbot.com/resources/courses/cypress/assertions-and-waiting)
5. [5 Fixtures and Network Stubbing with cy.intercept](https://testingbot.com/resources/courses/cypress/fixtures-and-network-stubbing)
6. [6 Custom Commands and Logging In Once with cy.session](https://testingbot.com/resources/courses/cypress/custom-commands-and-sessions)
7. [7 Cypress Configuration, Environment Variables and Retries](https://testingbot.com/resources/courses/cypress/config-and-environment-variables)
8. [8 Cypress Component Testing vs End-to-End Testing](https://testingbot.com/resources/courses/cypress/component-testing)
9. [9 Run Cypress on TestingBot and in CI](https://testingbot.com/resources/courses/cypress/run-cypress-on-testingbot)
10. [10 Debugging Cypress Tests](https://testingbot.com/resources/courses/cypress/debugging-cypress-tests)
11. [11 Knowledge check](https://testingbot.com/resources/courses/cypress/knowledge-check)

[Exit course](https://testingbot.com/resources/courses)

 Chapter 11 of 11 Beginner 5 min read Updated Nov 2026 

# Knowledge check
[Watch this chapter Starts at 8:38 in the 9:03 course video.](https://www.youtube.com/watch?v=Ty406iWkgN4&t=518s)

Nine questions on the decisions that matter most in a real Cypress suite. Each answer comes with a short explanation, so a wrong answer points you back to the right chapter.

1. A test clicks "Load more" and then runs `cy.wait(3000)` before checking that 20 rows exist. It is slow and still fails now and then. What is the better version?

 `cy.wait(5000)`, to leave more headroom Drop the wait and assert `cy.get('tbody tr').should('have.length', 20)`, raising that query's `timeout` if the server is slow Wrap the check in `.then()` so it runs after the click

The assertion retries until the rows are there and finishes as soon as they are. A longer sleep is slower and still a guess; `.then()` checks once and does not retry.

2. A spec has `const rows = cy.get('tbody tr')` followed by `if (rows.length > 0) { ... }`. The branch never runs. Why?

 The table had not rendered yet; add a timeout to `cy.get` `cy.get` returns a promise that must be awaited `cy.get` only queues a command and returns a chainer, which has no `length`; read the value inside `.then()`

No command has run when that line executes. Values from the page are only available in callbacks such as `.then()` or `.should()`, and awaiting a chainer does not work either.

3. Which selector is least likely to break when the design team restyles the checkout page?

 `cy.get('[data-cy=place-order]')` `cy.get('.btn.btn-lg.btn-success')` `cy.get('form > div:nth-child(4) > button')`

A dedicated test attribute has one job and does not change with styling or layout. Classes and structural paths change whenever the markup does.

4. You want to test how the orders page looks when the API returns an empty list. The real test account has 40 orders. What is the cleanest approach?

 Delete all orders with the UI in `beforeEach` `cy.intercept('GET', '/api/orders', { body: [] })` before visiting the page Create a second account by hand and hard-code its password in the spec

Stubbing the response gives you the exact state you want, instantly and without changing data. Register the intercept before the visit so the page's request is caught.

5. Every test in a 150-test suite logs in through the form, and the suite takes 25 minutes. What change helps most?

 Turn off test isolation so the login cookie survives between tests Put the login in a `before` hook in each spec Raise `retries` so slow logins get a second chance Wrap the login in `cy.session()` with a validate function, ideally logging in through the API

`cy.session` logs in once and restores the cookies and storage for each later test, while keeping tests isolated. Disabling isolation lets other state leak between tests too, and with isolation on, a `before` hook's login is cleared before the second test.

6. The same specs must run against localhost on laptops and against staging in CI. How should the URL be chosen?

 Use relative `cy.visit` paths and set `baseUrl`, overriding it in CI with `CYPRESS_BASE_URL` or `--config baseUrl=...` Keep two copies of the specs, one per environment Check `window.location.hostname` in every test

With relative paths, one setting decides where the whole suite points, and the specs never mention a host.

7. A test passes only on its second attempt in most CI runs. Retries keep the pipeline green. What should you do?

 Nothing; that is what retries are for Raise `retries` to 4 so it never fails Run it with retries off, read the failure screenshot, and find out whether the test or the application is wrong

A regular pass-on-retry is a bug report. In chapter 9 the cause was a real defect in the application (duplicate ids), which retries had been hiding.

8. You run `testingbot-cypress run` and nothing in your component tests runs on the grid. Why?

 Component specs must be listed with `--specs` TestingBot's Cypress documentation lists Component Testing as not supported; run those with `cypress run --component` locally or in CI Component tests only run in Electron

The grid runs your end-to-end specs. Component tests need your framework's dev server and stay on your machine or CI runner.

9. In GitHub Actions, the login spec passes on TestingBot from a laptop but fails from CI with an empty username. `cypress.env.json` is in `.gitignore`. What is the fix?

 Commit `cypress.env.json` Hard-code the credentials in `cypress.config.js` Set `TESTINGBOT_KEY` to the username Pass the values from repository secrets with the CLI's `--env username=...,password=...` flag

On a laptop the CLI uploads `cypress.env.json` with the project; in CI the file does not exist. `--env` sets Cypress environment variables on the remote run without putting secrets in the repository.

Check answers

[Previous · Chapter 10 Debugging Cypress Tests](https://testingbot.com/resources/courses/cypress/debugging-cypress-tests)
## You finished Cypress Tutorial: First Spec to CI

Put what you learned into practice. Run your tests on 6100+ real browsers and physical iOS and Android devices.

[Start free trial](https://testingbot.com/users/sign_up) [See pricing](https://testingbot.com/pricing) [Browse other courses](https://testingbot.com/resources/courses)

## TestingBot Cypress Certification

Turn this course into a free, resume-worthy credential: pass the exam, run the course suite on TestingBot, and get a verifiable certificate for your LinkedIn profile.

[How it works](https://testingbot.com/resources/courses/cypress/certification)
