+ /**
+ * Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
+ * @param {Object} test test details
+ */
+ beforeTest: function ( test ) {
+ if ( process.env.DISPLAY && process.env.DISPLAY.startsWith( ':' ) ) {
+ let videoPath = filePath( test, this.screenshotPath, 'mp4' );
+ const { spawn } = require( 'child_process' );
+ ffmpeg = spawn( 'ffmpeg', [
+ '-f', 'x11grab', // grab the X11 display
+ '-video_size', '1280x1024', // video size
+ '-i', process.env.DISPLAY, // input file url
+ '-loglevel', 'error', // log only errors
+ '-y', // overwrite output files without asking
+ '-pix_fmt', 'yuv420p', // QuickTime Player support, "Use -pix_fmt yuv420p for compatibility with outdated media players"
+ videoPath // output file
+ ] );
+
+ ffmpeg.stdout.on( 'data', ( data ) => {
+ console.log( `ffmpeg stdout: ${data}` );
+ } );
+
+ ffmpeg.stderr.on( 'data', ( data ) => {
+ console.log( `ffmpeg stderr: ${data}` );
+ } );
+
+ ffmpeg.on( 'close', ( code ) => {
+ console.log( '\n\tVideo location:', videoPath, '\n' );
+ console.log( `ffmpeg exited with code ${code}` );
+ } );
+ }
+ },
+