Complete the code to import a Cypress plugin.
const plugin = require('[1]');
The correct way to import a sample Cypress plugin is using its package name, like cypress-plugin-sample.
Complete the code to register a plugin in Cypress.
module.exports = (on, config) => { on('[1]', () => { /* plugin code */ }); };The task event is used to register custom tasks in Cypress plugins.
Fix the error in the plugin registration code by completing the blank.
module.exports = (on, config) => { on('task', [1]); };The task event expects an object mapping task names to functions, like { myTask: () => 'done' }.
Fill both blanks to correctly export a plugin that logs a message before tests run.
module.exports = (on, config) => { on('[1]', () => { console.log('[2]'); }); };The before:run event runs before tests start, and logging 'Tests are starting' informs about test execution beginning.
Fill both blanks to create a plugin that defines a custom task returning the current time.
module.exports = (on, config) => { on('[1]', { [2]: () => new Date().toISOString() }); };The task event registers tasks. Naming the task getCurrentTime and returning new Date().toISOString() provides the current time in ISO format.