0
0
Cypresstesting~5 mins

Base URL configuration in Cypress - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of setting a baseUrl in Cypress configuration?
Setting a baseUrl allows you to write shorter test commands by omitting the full URL. It helps tests run faster and makes them easier to maintain.
Click to reveal answer
beginner
Where do you set the baseUrl in a Cypress project?
You set the baseUrl in the cypress.config.js file under the e2e configuration object using the key 'baseUrl'.
Click to reveal answer
beginner
How does using baseUrl improve test code readability?
Instead of writing full URLs like 'https://example.com/login', you can write cy.visit('/login'). This makes test steps cleaner and easier to read.
Click to reveal answer
intermediate
Can you override the baseUrl for a single test in Cypress?
Yes, you can override the baseUrl by passing the full URL directly to cy.visit() or by setting environment variables for different test runs.
Click to reveal answer
beginner
Example of a valid baseUrl configuration in cypress.config.js?
import { defineConfig } from 'cypress';

export default defineConfig({
  e2e: {
    baseUrl: 'https://example.com'
  }
});
Click to reveal answer
Where is the baseUrl configured in a Cypress project?
AIn package.json
BInside each test file
CIn cypress.config.js under e2e
DIn the browser settings
What happens if you use cy.visit('/login') with baseUrl set to 'https://example.com'?
AIt throws an error
BIt visits /login on localhost
CIt visits https://login
DIt visits https://example.com/login
Can baseUrl be changed dynamically during test execution?
ANo, it is fixed in config
BYes, by passing full URLs to cy.visit()
CYes, by editing cypress.config.js mid-test
DNo, baseUrl is ignored
Why is using baseUrl recommended in Cypress tests?
ATo reduce typing and improve maintainability
BTo slow down tests
CTo avoid using cy.visit()
DTo disable tests
Which of these is a correct baseUrl value?
Ahttps://myapp.com
Bmyapp
Cftp://myapp.com
Dlocalhost
Explain how baseUrl configuration helps simplify Cypress test code.
Think about how you avoid repeating the full website address.
You got /4 concepts.
    Describe where and how to set the baseUrl in a Cypress project.
    Look for the main configuration file for Cypress tests.
    You got /4 concepts.