Cypress Junior interview questions and answers
75 questions for a Cypress (Junior) interview - with correct answers, explanations and links to the docs.
Take this quiz- 1.Where do Cypress tests run?
- 2.Which command opens the interactive Cypress app?
- 3.Which command runs all Cypress tests headlessly, e.g. in CI?
- 4.Where is the main Cypress configuration usually defined?
- 5.What does setting
baseUrlin the Cypress config allow? - 6.What is a spec file in Cypress?
- 7.Which functions structure Cypress tests?
- 8.What does
cy.visit('/products')do? - 9.What does
cy.get('[data-cy=submit]')do? - 10.Why does Cypress recommend
data-cyordata-testattributes for selectors? - 11.What does
cy.contains('Save')find? - 12.How do you type into an input in Cypress?
- 13.How do you press Enter after typing?
- 14.How do you select an option in a native
<select>? - 15.How do you tick a checkbox in Cypress?
- 16.What does Cypress check before clicking an element?
- 17.What does
{ force: true }on a click do, and why is it risky? - 18.What does
.should('be.visible')do? - 19.Which assertion checks an input's value?
- 20.How do you check a list has exactly 3 items?
- 21.How do you assert an element is NOT on the page?
- 22.Which assertion checks the current URL contains
/dashboard? - 23.What is the default timeout for most Cypress queries like
cy.get? - 24.Why should you avoid
cy.wait(5000)in tests? - 25.What are Cypress commands, in terms of timing?
- 26.Why can't you write
const btn = cy.get('button')and usebtnas an element? - 27.What does
.then()give you in Cypress? - 28.What does
.as('user')do? - 29.What does
cy.intercept()let you do? - 30.How do you wait for a request before asserting the UI?
- 31.How do you stub an API response with fixed data?
- 32.What are fixtures in Cypress?
- 33.What does
cy.request()do? - 34.Why log in through
cy.requestorcy.sessioninstead of the UI in most tests? - 35.What does
cy.session()do? - 36.What is test isolation in Cypress?
- 37.Why shouldn't one test depend on another test's result?
- 38.How do you run only one test while working on it?
- 39.How do you skip a test?
- 40.Where should code that runs before each test, like
cy.visit('/'), go? - 41.What does
cy.viewport('iphone-x')do? - 42.What does
cy.screenshot()do? - 43.Which browsers can Cypress run tests in?
- 44.What does the Cypress command log show?
- 45.How do you pause a test to inspect the page in the Cypress app?
- 46.How do you scope queries to one part of the page?
- 47.How do you get the second item from a list?
- 48.How do you find a child element of a found element?
- 49.How do you read environment-specific values in Cypress?
- 50.Why should secrets not be committed in
cypress.env.json? - 51.What is a custom command?
- 52.Where are custom commands usually registered?
- 53.What does
cy.task()do? - 54.How do you test a feature that depends on time, like a countdown?
- 55.What does
cy.stub()create? - 56.What happens to a
window.alert()in a Cypress test? - 57.Why does Cypress record screenshots on failure in
cypress run? - 58.What is Cypress component testing?
- 59.What does the Cypress Testing Library add?
- 60.How can test retries be enabled in Cypress?
- 61.Why does a hard-coded
cy.wait(2000)before checking a result usually fail sometimes? - 62.What should a Cypress test check after submitting a form?
- 63.What does
cy.reload()do? - 64.What does
cy.go('back')do? - 65.How do you test a file upload in Cypress?
- 66.How do you assert that a text appears somewhere in an element?
- 67.What is the role of the support file
cypress/support/e2e.ts? - 68.Why is
cy.get('.btn-primary:nth-child(3)')a fragile selector? - 69.What does Cypress do with an uncaught exception from the app?
- 70.How do you run one spec file from the command line?
- 71.What does Cypress Cloud add on top of the open-source runner?
- 72.Why should tests clean up or create their own data?
- 73.What is a common mistake when asserting on text that loads asynchronously?
- 74.How does Cypress handle a click that triggers navigation?
- 75.Which kind of tests does Cypress mainly target?