Bird
0
0

Given this cypress.config.js snippet:

medium📝 Predict Output Q13 of 15
Cypress - Test Organization and Patterns
Given this cypress.config.js snippet:
export default defineConfig({
  env: {
    username: 'user1',
    password: 'pass1'
  }
})

What will console.log(Cypress.env('username')) print during a test?
Anull
B'username'
C'user1'
Dundefined
Step-by-Step Solution
Solution:
  1. Step 1: Check env object in config

    The config sets env.username to 'user1'.
  2. Step 2: Understand Cypress.env() behavior

    Cypress.env('username') returns the value of the username key from env, which is 'user1'.
  3. Final Answer:

    'user1' -> Option C
  4. Quick Check:

    Env username value = 'user1' [OK]
Quick Trick: Cypress.env('key') returns the value set in config env [OK]
Common Mistakes:
  • Expecting the key name instead of its value
  • Assuming undefined if not set in test code
  • Confusing Cypress.env() with Cypress.config()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes