Bird
0
0

You wrote a custom command in cypress/support/commands.js but it is not recognized in your tests. What is the most likely cause?

medium📝 Debug Q6 of 15
Cypress - Basics and Setup
You wrote a custom command in cypress/support/commands.js but it is not recognized in your tests. What is the most likely cause?
AYou placed 'commands.js' inside 'fixtures' folder instead
BYou forgot to import 'commands.js' in 'support/index.js' file
CYou wrote the command inside 'integration' folder
DYou did not restart Cypress after adding the command
Step-by-Step Solution
Solution:
  1. Step 1: Check how Cypress loads commands

    Cypress loads commands if they are imported in support/index.js.
  2. Step 2: Identify missing import issue

    If commands.js is not imported in support/index.js, commands won't be available.
  3. Final Answer:

    You forgot to import 'commands.js' in 'support/index.js' file -> Option B
  4. Quick Check:

    Import commands in support/index.js [OK]
Quick Trick: Always import commands.js in support/index.js [OK]
Common Mistakes:
  • Not importing commands.js
  • Placing commands in wrong folder
  • Assuming restart fixes import issues

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes