0
0
Cypresstesting~10 mins

Why plugins extend Cypress capabilities - Test Your Understanding

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

Complete the code to import a Cypress plugin.

Cypress
const plugin = require('[1]');
Drag options to blanks, or click blank then click option'
Acypress-plugin
Bcypress/plugins
C@cypress/plugin
Dcypress-plugin-sample
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect or non-existent plugin paths.
2fill in blank
medium

Complete the code to register a plugin in Cypress.

Cypress
module.exports = (on, config) => { on('[1]', () => { /* plugin code */ }); };
Drag options to blanks, or click blank then click option'
Awindow:before:load
Bbefore:run
Ctask
Dafter:spec
Attempts:
3 left
💡 Hint
Common Mistakes
Using events that are not for plugin tasks.
3fill in blank
hard

Fix the error in the plugin registration code by completing the blank.

Cypress
module.exports = (on, config) => { on('task', [1]); };
Drag options to blanks, or click blank then click option'
A{ myTask: () => 'done' }
B() => console.log('task')
C() => { return null; }
Dfunction() { console.log('task'); }
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a function instead of an object for tasks.
4fill in blank
hard

Fill both blanks to correctly export a plugin that logs a message before tests run.

Cypress
module.exports = (on, config) => { on('[1]', () => { console.log('[2]'); }); };
Drag options to blanks, or click blank then click option'
Abefore:run
Btask
CTests are starting
DPlugin loaded
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong event names or unclear log messages.
5fill in blank
hard

Fill both blanks to create a plugin that defines a custom task returning the current time.

Cypress
module.exports = (on, config) => { on('[1]', { [2]: () => new Date().toISOString() }); };
Drag options to blanks, or click blank then click option'
Atask
BgetCurrentTime
CcurrentTime
DlogTime
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect event names or unclear task names.