0
0
Cypresstesting~10 mins

Base URL configuration in Cypress - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the base URL in Cypress configuration.

Cypress
cy.visit('[1]/login')
Drag options to blanks, or click blank then click option'
Aurl
BbaseUrl
Clocalhost
Dhttp://localhost:3000
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'baseUrl' directly inside cy.visit() without configuration.
Using incomplete URLs without protocol.
2fill in blank
medium

Complete the code to set the base URL in the Cypress config file (cypress.config.js).

Cypress
export default defineConfig({
  e2e: {
    [1]: 'http://localhost:3000'
  }
})
Drag options to blanks, or click blank then click option'
Aurl
BbaseUrl
CsiteUrl
DrootUrl
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect property names like 'url' or 'siteUrl'.
Forgetting to export the config properly.
3fill in blank
hard

Fix the error in the Cypress test to use the base URL correctly.

Cypress
cy.visit('[1]/dashboard')
Drag options to blanks, or click blank then click option'
A/dashboard
Bhttp://localhost:3000
Cdashboard
Dlocalhost:3000
Attempts:
3 left
💡 Hint
Common Mistakes
Using full URLs in cy.visit() when baseUrl is set.
Omitting the leading slash in relative paths.
4fill in blank
hard

Fill both blanks to correctly configure baseUrl and use it in a test.

Cypress
export default defineConfig({
  e2e: {
    [1]: 'http://example.com'
  }
})

// In test file
cy.visit([2])
Drag options to blanks, or click blank then click option'
AbaseUrl
B'/home'
Durl
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'url' instead of 'baseUrl' in config.
Not using quotes around the path string.
5fill in blank
hard

Fill all three blanks to configure baseUrl, write a test visiting a page, and assert the URL.

Cypress
export default defineConfig({
  e2e: {
    [1]: 'http://myapp.test'
  }
})

describe('Home page test', () => {
  it('should load home page', () => {
    cy.visit([2])
    cy.url().should('include', [3])
  })
})
Drag options to blanks, or click blank then click option'
AbaseUrl
B'/'
D'/home'
Attempts:
3 left
💡 Hint
Common Mistakes
Using full URLs in cy.visit() when baseUrl is set.
Mismatching the path and assertion strings.