Bird
0
0

How can you mount a Vue component with a global plugin (e.g., Vue Router) in Cypress tests?

hard📝 Application Q9 of 15
Cypress - Component Testing
How can you mount a Vue component with a global plugin (e.g., Vue Router) in Cypress tests?
APass the plugin in the <code>global.plugins</code> array inside the mount options.
BImport the plugin inside the component and mount normally.
CMount the component twice, once with and once without the plugin.
DPlugins cannot be used when mounting components in Cypress.
Step-by-Step Solution
Solution:
  1. Step 1: Recall how to add global plugins in Cypress mount

    Mount options accept a global object where plugins can be added in the plugins array.
  2. Step 2: Evaluate other options

    Importing plugin inside component or mounting twice is incorrect. Plugins can be used when mounting.
  3. Final Answer:

    Pass the plugin in the global.plugins array inside the mount options. -> Option A
  4. Quick Check:

    Use global.plugins array to add plugins in mount [OK]
Quick Trick: Add plugins via global.plugins in mount options [OK]
Common Mistakes:
  • Trying to import plugins inside components for tests
  • Mounting component multiple times unnecessarily
  • Believing plugins can't be used in mount

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cypress Quizzes