DEV Community

Michal Bryxí
Michal Bryxí

Posted on

Testing EmberJS app in Chrome in Docker

Assuming you already have an ember-cli app. First, let's create a Dockerfile:

# Dockerfile

FROM node:10-alpine

RUN npm install -g ember-cli

  echo >> /etc/apk/repositories  && \
  apk add chromium

WORKDIR /myapp

COPY . /myapp/

RUN yarn

CMD ["ember", "test"]
Enter fullscreen mode Exit fullscreen mode

Then you will need to alter your application testem.js. Note that we are not using Chrome, but Chromium:

module.exports = {
  test_page: 'tests/index.html?hidepassed',
  disable_watching: true,
  launch_in_ci: [
  launch_in_dev: [
  browser_args: {
    Chromium: {
      ci: [
        // --no-sandbox is needed when running Chrome inside a container
        // process.env.CI ? '--no-sandbox' : null,
Enter fullscreen mode Exit fullscreen mode

Build your container:

$ docker build -t myapp .
Enter fullscreen mode Exit fullscreen mode

And after this your tests should be able to run:

$ docker run myapp 
Could not start watchman
Visit for more info.
cleaning up...
Built project successfully. Stored in "/myapp/tmp/class-tests_dist-RpV40XiD.tmp".
ok 1 Chrome 68.0 - [3 ms] - ESLint | app: app.js
ok 2 Chrome 68.0 - [0 ms] - ESLint | app: resolver.js
ok 3 Chrome 68.0 - [0 ms] - ESLint | app: router.js
ok 4 Chrome 68.0 - [0 ms] - ESLint | tests: test-helper.js
ok 5 Chrome 68.0 - [2 ms] - ember-qunit: Ember.onerror validation: Ember.onerror is functioning properly

# tests 5
# pass  5
# skip  0
# fail  0

# ok
Enter fullscreen mode Exit fullscreen mode

Top comments (3)

thisismydesign profile image

For me this fails with "Failed to read DnsConfig." I could only find this question but no solution:

jrock2004 profile image
John Costanzo

What do you do for watchman? Is there concern on file size of image with chromium installed?

michalbryxi profile image
Michal Bryxí

If there is a need for watchman, it is certainly possible to install it. Last time I checked Apline and Debian had quite straightforward installation.

The image sizes are nothing small TBH, but gives you the whole UI testing options. Storage space is cheap, so never considered that an issue.