Karma jasmine tests under 2.0


#1

Hi,

I wanted to include karma tests on circle, but ran into the following error:

(node:2330) DeprecationWarning: process.EventEmitter is deprecated. Use require('events') instead.
INFO [karma]: Karma v0.12.37 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
ERROR [launcher]: No binary for Chrome browser on your platform.
  Please, set "CHROME_BIN" env variable.
npm ERR! Test failed.  See above for more details.
Exited with code 1

The newly added dependencies in package.json are:

    "jasmine-core": "^2.2.0",
    "karma": "^0.12.31",
    "karma-chrome-launcher": "^0.1.7",
    "karma-coverage": "^1.1.1",
    "karma-jasmine": "^0.3.5"

I’ve tried many approaches, including:

image cache not found on this host

** ref2: Installing Chrome inside of your Docker Container, and got the following error:

dpkg: error processing package google-chrome-stable (--install):
 dependency problems - leaving unconfigured
  • include a chrome image emmenko/nodejs-karma, but selenium/standalone-chrome:3.1.0 image failed with: Exited with code 1xvfb-run: error: Xvfb failed to start

#2

I recommend using one of our browser images https://circleci.com/docs/2.0/circleci-images/


#3

Thanks rohara.

I’m using image: circleci/python:3.4-browsers, and have the following error:

_XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be created.

also, selenium/standalone-chrome:3.1.0 continued to fail with

Exited with code 1xvfb-run: error: Xvfb failed to start

however, if I remove image: circleci/python:3.4-browsers, then selenium/standalone-chrome:3.1.0 works as expected.

list of docker images I’m using originally:

  • image: python:3.4.4
  • image: mysql:5.7
  • image: selenium/standalone-chrome:3.1.0

#4

That’s a warning- just ignore it.

You don’t need that image now. Just use the CircleCI Python image alongside the MySQL one.


#5

unfortunately, I have selenium tests in the code as well. Since the selenium image did not build successfully, all of the selenium tests failed.


#6

Just install Selenium on the base container you’re running tests in. You already have chromedriver, Chrome and Firefox installed, you just need Selenium via the package manager of your choosing.


#7

i’m confused. :confused:
i already have selenium==3.3.1 listed in requirements.txt for python & "selenium-webdriver": "3.4.0" in package.json for node.

yet none of the selenium tests passes unless i included the selenium image.


#8

Maybe you need to download it manually;

http://selenium-release.storage.googleapis.com/3.4/selenium-server-standalone-3.4.0.jar


#9

still not working :disappointed:

current circle.yml:

version: 2
jobs:
  build:
    working_directory: ...
    docker:
      - image: python:3.4.4
      - image: circleci/python:3.4-browsers
        environment:
          CHROME_BIN: "/usr/bin/google-chrome"
      - image: mysql:5.7
    steps:
      - checkout
      - run:
          name: Install Dependencies
          command: ...
      - run:
          name: Install Selenium
          command: wget http://selenium-release.storage.googleapis.com/3.4/selenium-server-standalone-3.4.0.jar
      - run:
          name: Run Tests (including selenium)
          command: tox
      - run:
          name: Run Karma Tests
          command: npm test

in circle, install selenium completed successfully:

....

2017-05-25 21:33:42 (18.9 MB/s) - ‘selenium-server-standalone-3.4.0.jar’ saved [21763199/21763199]

but selenium tests continued to fail with

ConnectionRefusedError: [Errno 111] Connection refused

in addition, I tried to re-arrange the tests, so karma tests would run first. Then, I continue to get the following error:

ERROR [launcher]: No binary for Chrome browser on your platform.
  Please, set "CHROME_BIN" env variable.

#10

Remove that first image. You’re not using circleci/python:3.4-browsers with the config you’re using.


#11

without python:3.4.4 i’m getting Permission denied errors during the ‘Install Dependencies’ step:

+ apt-get update
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
Error executing command, exiting
Exited with code 1

#12

sudo apt-get update

The user is circleci not root. Sorry for not mentioning that.

If you have any caches, you might need to change the cache key to mitigate permissions errors there, too.


#13

i don’t actually have restore_cache & save_cache enabled for the dependency update, but i think there’s some secret caching going on?

tried rebuild without cache, tried sudo apt-get clean, & tried with an updated image (from circleci/python:3.4-browsers to circleci/python:3.4.6-browsers

but i’m still getting permission denied error.


#14

No.

Can you link me to that build?


#15

here is the build.

i’m getting the same error when running circleci build locally as well.


#16

You’re downloading a script and piping it to bash but it needs root privileges. Just change bash - to sudo bash -


#18

thanks rohara.

finally got karma working. :smile:

however i’m still struggling to get selenium working, with the same error :worried:

the latest build is here.


#19

finally got it working. :smile:

it wasn’t anything wrong with circle.yml, but i had to change the selenium chromedriver in python, since the image got changed.

thanks for all the help =)


#20

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.