Tests doesn't run without the GUI because of the error with video capture.
$ DEBUG=cypress:server:video node_modules/.bin/cypress run
====================================================================================================
(Run Starting)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Cypress: 3.1.4 โ
โ Browser: Electron 59 (headless) โ
โ Specs: 1 found (ordering.spec.js) โ
โ Searched: cypress/integration/ordering.spec.js โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Running: ordering.spec.js... (1 of 1)
cypress:server:video capture started { command: 'ffmpeg -n 20 /home/yuri/.cache/Cypress/3.1.4/Cypress/resources/app/packages/server/node_modules/@ffmpeg-installer/linux-x64/ffmpeg -f image2pipe -use_wallclock_as_timestamps 1 -i pipe:0 -y -vcodec libx264 -preset ultrafast /srv/http/s1/cypress/videos/ordering.spec.js.mp4' } +0ms
cypress:server:video capture stderr log { message: 'ffmpeg version N-45896-g19c3df0cd-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2018 the FFmpeg developers' } +3ms
cypress:server:video capture stderr log { message: ' built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516' } +1ms
cypress:server:video capture stderr log { message: ' configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg' } +0ms
cypress:server:video capture stderr log { message: ' libavutil 56. 17.100 / 56. 17.100' } +0ms
cypress:server:video capture stderr log { message: ' libavcodec 58. 19.100 / 58. 19.100' } +1ms
cypress:server:video capture stderr log { message: ' libavformat 58. 13.100 / 58. 13.100' } +0ms
cypress:server:video capture stderr log { message: ' libavdevice 58. 4.100 / 58. 4.100' } +0ms
cypress:server:video capture stderr log { message: ' libavfilter 7. 20.100 / 7. 20.100' } +0ms
cypress:server:video capture stderr log { message: ' libswscale 5. 2.100 / 5. 2.100' } +0ms
cypress:server:video capture stderr log { message: ' libswresample 3. 2.100 / 3. 2.100' } +0ms
cypress:server:video capture stderr log { message: ' libpostproc 55. 2.100 / 55. 2.100' } +13ms
cypress:server:video capture stderr log { message: '[mjpeg @ 0x6883000] EOI missing, emulating' } +370ms
ordering
cypress:server:video capture stderr log { message: 'Input #0, image2pipe, from \'pipe:0\':' } +7s
cypress:server:video capture stderr log { message: ' Duration: N/A, start: 1550258710.960000, bitrate: N/A' } +0ms
cypress:server:video capture stderr log { message: ' Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1023x575 [SAR 1:1 DAR 1023:575], 25 fps, 25 tbr, 25 tbn, 25 tbc' } +0ms
cypress:server:video capture stderr log { message: 'Stream mapping:' } +1ms
cypress:server:video capture codec data: { format: 'image2pipe', audio: '', video: 'mjpeg', duration: 'N/A', video_details: [ 'mjpeg', 'yuvj420p(pc', 'bt470bg/unknown/unknown)', '1023x575 [SAR 1:1 DAR 1023:575]', '25 fps', '25 tbr', '25 tbn', '25 tbc' ] } +0ms
cypress:server:video capture stderr log { message: ' Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))' } +3ms
cypress:server:video capture stderr log { message: '[libx264 @ 0x6887a00] width not divisible by 2 (1023x575)' } +3ms
cypress:server:video capture stderr log { message: 'Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height' } +0ms
cypress:server:video capture stderr log { message: 'Conversion failed!' } +2ms
cypress:server:video capture stderr log { message: '' } +1ms
cypress:server:video capture errored: { error: 'ffmpeg exited with code 1: Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height\nConversion failed!\n', stdout: '', stderr: 'ffmpeg version N-45896-g19c3df0cd-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2018 the FFmpeg developers\n built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516\n configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg\n libavutil 56. 17.100 / 56. 17.100\n libavcodec 58. 19.100 / 58. 19.100\n libavformat 58. 13.100 / 58. 13.100\n libavdevice 58. 4.100 / 58. 4.100\n libavfilter 7. 20.100 / 7. 20.100\n libswscale 5. 2.100 / 5. 2.100\n libswresample 3. 2.100 / 3. 2.100\n libpostproc 55. 2.100 / 55. 2.100\n[mjpeg @ 0x6883000] EOI missing, emulating\nInput #0, image2pipe, from \'pipe:0\':\n Duration: N/A, start: 1550258710.960000, bitrate: N/A\n Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1023x575 [SAR 1:1 DAR 1023:575], 25 fps, 25 tbr, 25 tbn, 25 tbc\nStream mapping:\n Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))\n[libx264 @ 0x6887a00] width not divisible by 2 (1023x575)\nError initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height\nConversion failed!\n' } +1ms
Warning: We failed to record the video.
This error will not alter the exit code.
Error: ffmpeg exited with code 1: Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
at ChildProcess.<anonymous> (/home/yuri/.cache/Cypress/3.1.4/Cypress/resources/app/packages/server/node_modules/fluent-ffmpeg/lib/processor.js:182:22)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
{ Error: ffmpeg exited with code 1: Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
at ChildProcess.<anonymous> (/home/yuri/.cache/Cypress/3.1.4/Cypress/resources/app/packages/server/node_modules/fluent-ffmpeg/lib/processor.js:182:22)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
recordingVideoFailed: true }
Error: ffmpeg exited with code 1: Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
at ChildProcess.<anonymous> (/home/yuri/.cache/Cypress/3.1.4/Cypress/resources/app/packages/server/node_modules/fluent-ffmpeg/lib/processor.js:182:22)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
$ xrandr
Screen 0: minimum 8 x 8, current 1024 x 576, maximum 32767 x 32767
eDP1 connected primary 1024x576+0+0 (normal left inverted right x axis y axis) 290mm x 170mm
1920x1080 60.00 + 59.93 40.00
1680x1050 59.88
1400x1050 59.98
1600x900 60.00 59.95 59.82
1280x1024 60.02
1400x900 59.96 59.88
1280x960 60.00
1368x768 60.00 59.88 59.85
1280x800 59.81 59.91
1280x720 59.86 60.00 59.74
1024x768 60.00
1024x576 60.00* 59.90 59.82
960x540 60.00 59.63 59.82
800x600 60.32 56.25
864x486 60.00 59.92 59.57
640x480 59.94
720x405 59.51 60.00 58.99
640x360 59.84 59.32 60.00
DP1 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)
Tests run.
And by the way, isn't it supposed to run all the tests even if it can't record the video?
Run the following test without GUI:
describe('My First Test', function() {
it('Visits the Kitchen Sink', function() {
cy.wait(3000); // or more to make it finish abnormally (prematurely)
// low values still produce an error, but tests continue to run
})
})
$ npx cypress run
If your screen resolution is greater than 1280x720. Otherwise:
$ xvfb-run -s '-screen 0 1280x720x24' npx cypress run
electron bug: Screen dimensions are off by one pixel in offscreen mode.
$ xvfb-run -s '-screen 0 1280x800x24' npx cypress run
Add .outputOptions("-vf pad=ceil(iw/2)*2:ceil(ih/2)*2") after the following line. Based on the following Stack Overflow answer. This fixes it for me.
Or probably .videoFilter('pad=ceil(iw/2)*2:ceil(ih/2)*2').
cypress-3.1.4, Arch Linux, Electron 59 (headless)
Supposedly it happens when screen size (particularly height) is less than or equal to requested browser size (1280x720).
requested -> real (passed to paint event handler)
1024x576 -> 1023x575
1280x720 -> 1279x719
1280x800 -> 1280x720
1368x768 -> 1280x720
Hey @x-yuri, could you provide an example of a failing test file? Are you setting the size using cy.viewport()?
// see original post
describe('My First Test', function() {
it('Visits the Kitchen Sink', function() {
cy.visit('https://example.cypress.io')
})
})
I'm not using cy.viewport(). Try with screen resolution less than 1280x720.
I am using cy.viewport(), but have a same problem too.. How I can fix it?
@narinepoghosyan The answer was in one of the previous posts, but to add more details, you've got to change
~/.cache/Cypress/3.1.4/Cypress/resources/app/packages/server/lib/video_capture.js
Add
.outputOptions("-vf pad=ceil(iw/2)*2:ceil(ih/2)*2
or
.videoFilter('pad=ceil(iw/2)*2:ceil(ih/2)*2')
after
.outputOptions("-preset ultrafast")
Or make resolution bigger than 1280x720, or possibly more.
As you might see, I've found a way to reproduce it without cypress. Under certain conditions (offscreen mode, show: false, (width == 1280, height == 720) >= (real_screen_width, real_screen_height), is there a way to change the 1280/720 thing?):
screen.width == real_screen_width - 1
screen.height == real_screen_height - 1
But I wonder if it's okay to demand a window to fit the screen. Generally that is not possible, since there usually exist some sort of a taskbar.
Solved by adding xvfb-run -s '-screen 0 1280x800x24' before cypress run
Indeed with -s '-screen 0 1280x720x24' it fails, but increasing either of those makes it work.
Most helpful comment
Solved by adding
xvfb-run -s '-screen 0 1280x800x24'beforecypress run