travis: sh: 0: Can't open /etc/init.d/xvfb
The solution was to remove sh -e /etc/init.d/xvfb start
from the before_script
array and simply introduce xvfb
in the services
array.
So my .travis.yml
now looks like this:
language: node_js
node_js:
- '10'
dist: xenial
sudo: required
services:
- xvfb
addons:
chrome: stable
before_script:
- export DISPLAY=:99.0
install:
- npm set progress=false
- npm install
script:
- ng lint
- npm run test
- npm run e2e
- npm run build
In addition to accepted answer I would say the result config should be a bit clearer in accordance to travis docs Using xvfb to Run Tests That Require a GUI. You don't need to set DISPLAY
, so before_script
section becomes excessive:
This only works on Ubuntu 16.04 (Xenial) and later on releases i.e. with dist: xenial or dist: bionic
The following will start xvfb and set the right values for the DISPLAY environment variable...
Also you don't need to specify dist in 2019 for node_js, because xenial
is the default image for node_js
language now (blogpost). Previously it was trusty
, so another possible solution might be in specifying dist as trusty
(see the doc). But speaking of default, the discussed config might look like
language: node_js
node_js:
- '10'
sudo: required
services:
- xvfb
addons:
chrome: stable
install:
- npm set progress=false
- npm install
script:
- ng lint
- npm run test
- npm run e2e
- npm run build