trigger a function after video processing
See original GitHub issueI’m running Cypress in a Docker container, and I’m trying to fetch as much infos as possible about the executed test before closing the container.
So I created a plugin that will upload the screenshots & videos to S3 after the execution of the test, this plugin is triggered by the after
hook.
but I noticed that the uploaded video is the un-processed/un-compressed video.
is there any way to trigger the video upload after the processing is finished ?
PS: I tried to put a listener on the exit
event so it can upload the video before closing the application, but it didn’t work for me.
this is a preview of the code I wrote:
- the hook:
after(function () {
cy.task('endMySession', null, {"log": false, "timeout": 180000});
});
- the plugin:
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
on('task', {
'endMySession': (args) => {
let promises = [];
promises.push(new Promise(function (resolve, reject) {
fs.readdir("./cypress/videos", (err, files) => {
if (err) {
return reject(err);
}
files.forEach((file,i) => {
promises.push(new Promise(function (resolve, reject) {
console.log("uploading " + file);
uploadFileToS3('my-video-bucket', "./cypress/videos/" + file, function (err, data) {
if (err) {
console.log('error uploading ' + file);
return reject(err);
}
console.log('uploaded ' + file);
resolve();
});
}));
resolve();
});
})
}));
return Promise.all(promises);
},
});
};
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How to trigger a function when 80% of the video has been ...
I currently manage to fire a method, once the movie ends and the total value of the amount played is equal to or...
Read more >Triggering a function when an Event Video ends - eLearning
1. Create a 'next' button and ID name it 'nextBtn'. · 2. Hide the button (press the eyeball) · 3. Import your event...
Read more >Trigger a timeline after playing Youtube Video - Tumult Forums
Hello everyone, It seems like a simple process, but I cannot get it. I am trying to trigger a timeline after I play...
Read more >Trigger Specific Actions on YouTube Video Player Events
You can do a lot using the YouTube IFrame API's JavaScript functions, from queueing videos for playback; playing, pausing, or stoping those ...
Read more >Video and Audio APIs - Learn web development | MDN
The very last piece of our media player to implement is the time-elapsed displays. To do this we'll run a function to update...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You should also be able to do this from within the Module API, since it returns the videos after a run. https://on.cypress.io/module-api
@tahayk since there’s not an event or lifecycle method that gets triggered after the screenshots are processed, I would stick with the Module API as @jennifer-shehane suggested. I put a basic repo together here -> https://github.com/testdrivenio/cypress-s3-upload.
It’s worth noting that there is an
test:after:run
event, but I had trouble getting it to work. https://github.com/cypress-io/cypress/issues/2271