diff --git a/.travis.yml b/.travis.yml index a1946ac7c1d..a462fc3da65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,29 +1,37 @@ +os: linux +dist: trusty + language: node_js -sudo: required node_js: - 'lts/*' + addons: chrome: stable - firefox: stable + firefox: latest + env: jobs: - - E2E_BROWSER=chrome - - E2E_BROWSER=firefox + - TEST_SUITE=unit + - TEST_SUITE=e2e-chrome + - TEST_SUITE=e2e-firefox global: - DISPLAY=:99.0 - NODE_ENV=test -dist: trusty + cache: yarn: true directories: - ~/.cache + before_install: - - "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16" - - curl -o- -L https://yarnpkg.com/install.sh | bash - - source ~/.bashrc - - sh -e /etc/init.d/xvfb start - - sleep 3 -script: make test + - '/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16' + - curl -o- -L https://yarnpkg.com/install.sh | bash + - source ~/.bashrc + - sh -e /etc/init.d/xvfb start + - sleep 3 + +script: make test-on-travis + branches: only: - master diff --git a/Makefile b/Makefile index e8c04c5b0da..b3c396bac2b 100644 --- a/Makefile +++ b/Makefile @@ -112,6 +112,19 @@ prettier: ## prettify the source code using prettier test: build test-unit lint test-e2e ## launch all tests +test-on-travis: build +ifeq ($(TEST_SUITE),unit) + $(MAKE) test-unit lint +else ifeq ($(TEST_SUITE),e2e-chrome) + BROWSER=chrome $(MAKE) test-e2e +else ifeq ($(TEST_SUITE),e2e-firefox) + BROWSER=firefox $(MAKE) test-e2e +else + @echo "Invalid test suite, please check your TEST_SUITE env var" + exit 1 +endif + + test-unit: ## launch unit tests @if [ "$(CI)" != "true" ]; then \ echo "Running unit tests..."; \ diff --git a/cypress/start.js b/cypress/start.js index 7c095a56fc0..843be4a593b 100644 --- a/cypress/start.js +++ b/cypress/start.js @@ -5,7 +5,7 @@ return server.start().then(listeningServer => { // kick off a cypress run return cypress .run({ - browser: process.env.E2E_BROWSER || 'chrome', + browser: process.env.BROWSER || 'chrome', config: { baseUrl: 'http://localhost:8080', video: false, @@ -17,5 +17,8 @@ return server.start().then(listeningServer => { if (results.totalFailed > 0) { process.exit(1); } + }) + .catch(() => { + process.exit(1); }); });