Ember.js - CircleCI - BrowserStack
Asked Answered
N

1

3

I try to connect together our cicleCI with browserstack and run our integration_test and unit tests not only with PhantomJS but on real Firefox and Internet Explorer as well, using Browserstack service.

I try to configure browserstack-cli. I can run the test from circleci via tunnel on Browserstack, but never report back to circleci server.

Could you please share your experience if you already played with this stack? Thank you very much!

Neustria answered 1/8, 2014 at 6:14 Comment(0)
N
1

The solution is to use BrowserStackLocal and browserstack-cli tools together. The 64bit linux version of BrowserStackLocal builds up the tunnel from circleCI server to Browserstack server. After that we can use browserstack-cli to launch browsers and running tests from testem.

Download BrowserStackLocal

and insert in .browserstack folder in your project.

Create a script,

which will run and create settings for browserstack-cli. You have to setup global variables in circleCI, and you can keep your access details there secretly. Let's call this file runthis.sh and save in .browserstack folder. This script will run your BrowserStackLocal binary as well, so the tunnel will be exist.


    #!/bin/bash
    echo "{\"username\":\"`echo $BS_USER`\", \"password\":\"`echo $BS_PASSWORD`\", \"privateKey\": \"`echo $BS_KEY`\", \"apiKey\":\"`echo $BS_KEY`\"}" >> ~/.browserstack/browserstack.json
    ./.browserstack/BrowserStackLocal $BS_KEY &

CircleCI config

(circle.yml) file mainly depend of your project. We have to copy .browserstack folder in home folder, install bower, browserstack-cli and testem.

An example:

 
machine:
  timezone:
    Pacific/Auckland
  node:
    version: v0.10.28

dependencies:
  pre:
    - mv ./.browserstack ~/
    - sh ~/.browserstack/runthis.sh

  post:
    - bower install
    - npm install browserstack-cli -g
    - npm install testem -g

test:
  override:
    - PATH=$PATH:bin grunt integration_tests_cli; testem ci
    - PATH=$PATH:bin grunt tests_cli; testem ci
 

Testem config:

testem.yml - Most of the part is depend of your project. Important in our case is launchers section.

 
framework: "qunit"
test_page: "tmp/index.html"

src_files:
  - "tmp/assets/application.js"
  - "tmp/tests.js"
  - "tmp/integration_tests.js"

launchers:
  bs_chrome:
    command: browserstack launch chrome --attach 
    protocol: browser
    timeout: 300

launch_in_ci:
  - "PhantomJS"
  - "bs_chrome"

launch_in_dev:
  - "Chrome"
  - "Firefox"
  - "PhantomJS"

parallel: 2

So, if you update your project on github, circleci will launch your test and connect to browserstack and gonna use browsers there...

Neustria answered 13/8, 2014 at 3:46 Comment(2)
don't you need to define a machine environment ? I'm getting the following error: "browserstack launch chrome --attach" exited unexpectedly with exit code 1. @NeustriaScurrile
@YoniDabush sorry, I don't use CircleCI/Browserstack at the moment, I cannot test it, but if the configuration is changed meanwhile, and you find the solution, please let me know and I update the answer. Thank you. :)Neustria

© 2022 - 2024 — McMap. All rights reserved.