Testing With Browser
ZD: https://gitlab.zendesk.com/agent/tickets/24415
Description
I can't convert this Travis stuff to GL, and I can't get it running. However. I can get it running with a headless browser such as PhantomJS, if I simplify everything down to this:
before_script:
- npm install
test:latest:
image: node:latest
script:
- npm test
This is a default docker image with latest node.js.
This is far away from the configuration we want.
Another issue here is that GL CI doesn't seem to run sequences or ASYNC? The npm test command, calls a Gulp task in sequence telling that both node.js and browser unit tests should be executed. However. The node.js unit tests kills the browser unit tests and mix them together, so the browser unit tests are never run.
I say so because of this output:
[14:52:20] Finished 'lint' after 5.42 μs
[14:52:20] Starting 'node:cov'...
[14:52:20] Starting 'test:browser'...
Both tests are starting at the same time? And only the node.js unit tests are completed.
But our main issue is that we can't get this running with a Chrome browser as in Travis, or with the same config as Travis. I come close to this, but not close enough.
If I re-write the .gitlab-ci.yml Into this
image: node:latest
cache:
paths:
- node_modules
before_script:
- apt-get update -qq
- apt-get install software-properties-common wget xvfb psmisc -qq
# - add-apt-repository -y ppa:ubuntu-toolchain-r/test
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
- echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
- apt-get update -qq
- apt-get install -qq google-chrome-stable google-chrome-beta
#- wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
#- source /root/.bashrc
#- nvm install 6
#- nvm use 6
#- which node
#- node --version
- npm install
# - npm install -g npm@3
# - npm config set spin false
# - npm config set loglevel http
- export DISPLAY=:99.0
- wget -O /etc/init.d/xvfb https://gist.githubusercontent.com/axilleas/3fc13e0c90ad9f58bee903a41e8a6d48/raw/169a60010635e05eaa902c5f3b4393321f2452f0/xvfb
- chmod 0755 /etc/init.d/xvfb
- sh -e /etc/init.d/xvfb start
build:
script:
- npm test
It will work, but Chrome can't start to run. I'm fully aware I have to add this one:
export CHROME_BIN=/usr/bin/google-chrome
Export the Chrome binaries. Else thing will not work in Linux world. But didn't help either.
That is the closest we got after 4 weeks.
So our goal to start with is to get the BP I linked to, to run on GL with Chrome as the browser and same config as Travis.yml have. Or CI.
Next step is also to get the same stuff work in matrix, and also both for Linux and OSX.
We are far far away from that.
I need to mention quickly here that we also tried to get this stuff working, because I earlier faced issued with Android as well. And there is a must to have it working both for Linux, Mac and Window. In travis you can set this up like this: os: - linux - osx
env:
global:
# - KARMA_JS_BROWSERS=ChromeNoSandbox
- LOGS_DIR=/tmp/angular-build/logs
- ARCH=linux-x64
matrix:
# Order: a slower build first, so that we don't occupy an idle travis worker waiting for others to complete.
- CI_MODE=js
- CI_MODE=lint
matrix:
allow_failures:
- env: ...
cache:
directories:
- $HOME/.pub-cache
- $HOME/.chrome/chromium
env:
global:
# Use newer verison of GCC to that is required to compile native npm modules for Node v4+ on Ubuntu Precise
# # more info: https://docs.travis-ci.com/user/languages/javascript-with-nodejs#Node.js-v4-(or-io.js-v3)-compiler-requirements
- CXX=g++-4.8
# No sandbox mode is needed for Chromium in Travis, it crashes otherwise: https://sites.google.com/a/chromium.org/chromedriver/help/chrome-doesn-t-start
- KARMA_JS_BROWSERS=ChromeNoSandbox
- LOGS_DIR=...
- ARCH=linux-x64
before_install:
export CHROME_BIN=$HOME/.chrome/chromium/chrome-linux/chrome
- export DISPLAY=:99.0
- export GIT_SHA=$(git rev-parse HEAD)
- ./scripts/ci/init_android.sh
sh -e /etc/init.d/xvfb start
/cc @ayufan