Skip to content

Commit

Permalink
ui: Test using Headless Chrome
Browse files Browse the repository at this point in the history
Begin running Karma tests using headless chrome instead of JSDOM. This
should ensure that our tests are running in the closest possible
environment to an actual browser.

Adds Chrome as a dependency to our builder image.

Release note (admin ui change): Running unit tests for the Admin UI now depend
on the installation of Google Chrome.
  • Loading branch information
Matt Tracy committed May 2, 2018
1 parent ddb3f13 commit 7e89701
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 183 deletions.
2 changes: 1 addition & 1 deletion build/builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -euo pipefail

image=cockroachdb/builder
version=20180405-182035
version=20180502-092643

function init() {
docker build --tag="${image}" "$(dirname "${0}")/builder"
Expand Down
6 changes: 5 additions & 1 deletion build/builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,24 @@ RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key ad
&& echo 'deb https://dl.yarnpkg.com/debian/ stable main' | tee /etc/apt/sources.list.d/yarn.list \
&& curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - \
&& echo 'deb https://packages.cloud.google.com/apt cloud-sdk-xenial main' | tee /etc/apt/sources.list.d/gcloud.list \
&& curl -fsSL https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" | tee /etc/apt/sources.list.d/google.list \
&& apt-get update

# ccache - speed up C and C++ compilation
# nodejs - ui
# openjdk-8-jre - railroad diagram generation
# google-cloud-sdk - roachprod acceptance tests
# yarn - ui
# chrome - ui
RUN apt-get install -y --no-install-recommends \
ccache \
google-cloud-sdk \
nodejs \
openjdk-8-jre \
openssh-client \
yarn
yarn \
google-chrome-stable

# Without CCACHE_CPP2=1, ccache can generate spurious warnings. See the manpage
# for details. This option is enabled by default in ccache v3.3+, but our
Expand Down
2 changes: 2 additions & 0 deletions pkg/ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Our UI is compiled using a collection of tools that depends on
[Node.js](https://nodejs.org/) and are managed with
[Yarn](https://yarnpkg.com), a package manager that offers more deterministic
package installation than NPM. NodeJS 6.x and Yarn 0.22.0 are known to work.
[Chrome](https://www.google.com/chrome/), Google's internet browser. Unit tests
are run using Chrome's "Headless" mode.

With Node and Yarn installed, bootstrap local development by running `make` in
this directory. This will run `yarn install` to install our Node dependencies,
Expand Down
2 changes: 1 addition & 1 deletion pkg/ui/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = function(config) {

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ["jsdom"],
browsers: ["ChromeHeadless"],

// enable / disable colors in the output (reporters and logs)
colors: true,
Expand Down
6 changes: 2 additions & 4 deletions pkg/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"react": "^16.3.1",
"react-addons-create-fragment": "^15.4.2",
"react-copy-to-clipboard": "^5.0.1",
"react-motion": "^0.5.2",
"react-dom": "^16.3.1",
"react-helmet": "^5.2.0",
"react-motion": "^0.5.2",
"react-paginate": "^5.2.2",
"react-redux": "^5.0.3",
"react-router": "^3.2.1",
Expand Down Expand Up @@ -81,11 +81,9 @@
"html-webpack-plugin": "^2.30.1",
"html-webpack-template": "^6.0.1",
"http-proxy-middleware": "^0.17.4",
"jsdom": "^9.12.0",
"karma": "^1.5.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.0.0",
"karma-jsdom-launcher": "^6.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.3",
"karma-sinon": "^1.0.5",
Expand Down
Loading

0 comments on commit 7e89701

Please sign in to comment.