0

I have an electron project with spectron tests. I use travis to build for every major OS with electron-builder. Now, I want to also run tests in travis, so I updated my .travis.yml file to run tests on linux (for headless tests) and build on osx. This works, but only the build part on osx works, while the tests fails.

This is my last try of travis config

language: node_js

matrix:
  include:
    - os: linux
    - os: osx
      osx_image: xcode10.2

node_js: '12'

addons:
  chrome: stable
  apt:
    packages:
      - xvfb

script:
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then xvfb-run test; fi
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then npm run dist; fi

This fails without any valuable information

enter image description here

I have also tried this travis config

addons:
  apt:
    packages:
      - xvfb

before_script:
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export DISPLAY=:99.0; fi
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sh -e /etc/init.d/xvfb start; fi
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sleep 3; fi

script:
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then npm test; fi
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then npm run dist; fi

that one fails because of timeout after 10 minutes. So I have no clue here of what it is going on. How can I tests my electron app in travis while also keeping the build on osx? Is there anything wrong on my travis config?

PD: Here is the repo where I have my project

Yerko Palma
  • 12,041
  • 5
  • 33
  • 57

1 Answers1

0

Is it possible that you want to call

xvfb-run npm test

instead of

xvfb-run test

?

Otherwise, xvfb-run test will call the test command (reference) which returns 1 because there's no expression given i.e. expression evaluates to false.

Dominic Jodoin
  • 2,538
  • 18
  • 21