-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plugin: use command:start command:end #2177
Comments
Plugin events are limited to what's listed here. The The 'task' event in conjunction with cy.task() is perfect for your use-case, bridging the gap between the browser and the background process: // in your test file or support file
Cypress.on('command:start', (command) => {
// very important! otherwise we end up in an infinite loop
if (command.get('name') === 'task') return
cy.task('command:start')
})
Cypress.on('command:end', (command) => {
// very important! otherwise we end up in an infinite loop
if (command.get('name') === 'task') return
cy.task('command:end', command.get('name'))
})
// in your plugins file
module.exports = (on, config) => {
on('task', {
'command:start' (command) {
console.log(command + ":started at "+new Date().getTime())
return null
},
'command:end' (command) {
console.log(command + ":end at "+new Date().getTime())
return null
},
})
} |
We could also add additional plugins events that match up to the browser events. You won't be able to interface or do anything to control Cypress that's running in the browser, but you could log / list them out if need be. The problem with trying to run tasks from within this is that they will only be enqueued in the command pipeline, and will not be run until other commands finish. There is an undocumented way to kick off commands immediately without them being enqueued where they act like a regular promise - which is
Ideally we just automatically synchronize and add all events in both the background node and browser processes so you don't have to do wire these up manually. |
@chrisbreiding @brian-mann coool, thanks a lot 😄 that's what I was looking for. |
Hey
I'm trying to create my own plugin for reporting purposes,
so I want to monitor each command execution time+arguments, but I couldn't find a way to do it.
is it possible to use a plugin like:
so basically I'm trying to create something like the command log for my personal reporting requirements.
![image](https://user-images.githubusercontent.com/22003449/42954572-fb08fd8c-8b74-11e8-9348-d28e91f263ca.png)
The text was updated successfully, but these errors were encountered: