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?
✗ Incorrect
The baseUrl is set in cypress.config.js inside the e2e configuration object.
What happens if you use cy.visit('/login') with baseUrl set to 'https://example.com'?
✗ Incorrect
With baseUrl set, relative paths in cy.visit() append to the baseUrl.
Can baseUrl be changed dynamically during test execution?
✗ Incorrect
You can override baseUrl by passing full URLs directly to cy.visit().
Why is using baseUrl recommended in Cypress tests?
✗ Incorrect
Using baseUrl makes test code shorter and easier to update.
Which of these is a correct baseUrl value?
✗ Incorrect
baseUrl should be a valid URL starting with http or https.
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.