e2e test with Jenkins, selenium-grid and protractor - node.js

I'm trying to build my testing environment using Jenkins, Selenium and Protractor. I decided to use selenium-plugin (selenium grid) to dispatch tests among remote machines (nodes). What I achieved till now is establishing connection between selenium hub and nodes.
Node.js version installed on Jenkins is 5.12.0, Protractor is 3.3.0. I also installed npm chromedriver and set a path to this driver in protractor.config.js like :
chromeDriver: '/u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/chromedriver/bin/chromedriver'
Nodes are running selenium-standalone servers, installed globaly with npm.
When I'm executing my protractor.config.js file I have the following error :
protractor /u01/apps/jenkins/data/workspace/Servers/testApp/protractor.conf.js
[14:49:08] I/direct - Using ChromeDriver directly...
[14:49:08] I/launcher - Running 1 instances of WebDriver
/u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1329
return callbackFn(this.value_);
^
Error: Server terminated early with status 127
at Error (native)
at /u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/remote/index.js:210:20
at Promise.invokeCallback_ (/u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1329:14)
at TaskQueue.execute_ (/u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2790:14)
at TaskQueue.executeNext_ (/u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2773:21)
at /u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2652:27
at /u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
at acquireSession (/u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:62:22)
at Function.createSession (/u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:295:12)
at Driver (/u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/protractor/node_modules/selenium-webdriver/chrome.js:778:38)
at Direct.getNewDriver (/u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/protractor/built/driverProviders/direct.js:65:26)
at Runner.createBrowser (/u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/protractor/built/runner.js:182:43)
at /u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/protractor/built/runner.js:255:30
at _fulfilled (/u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/protractor/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/protractor/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/protractor/node_modules/q/q.js:796:13)
at /u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/protractor/node_modules/q/q.js:556:49
[14:49:08] E/launcher - Process exited with error code 1
Here is my protractor config file:
exports.config = {
directConnect: true,
chromeDriver: '/u01/apps/jenkins/data/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_5.12.0/lib/node_modules/chromedriver/bin/chromedriver',
framework: 'jasmine',
capabilities: {
'browserName': 'chrome',
shardTestFiles: true,
maxInstances: 3
},
specs: ['test/test_spec.js'],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
},
seleniumAddress: 'http://HUB_IP:4444/wd/hub',
onPrepare: function() {
browser.driver.manage().window().maximize();
},
plugins: [{
package: 'protractor-console',
logLevels: ['severe', 'debug', 'info', 'warning']
}]
};

You need to directConnect: false, so it will use the selenium server through seleniumAddress: 'http://HUB_IP:4444/wd/hub', and given you are on Jenkins, probably in headless mode I recommend you to use docker-selenium
Start the local grid
CONTAINER_ID="grid_$BUILD_NUMBER"
docker run -d --name=$CONTAINER_ID -v /dev/shm:/dev/shm elgalu/selenium
Wait for it to start
docker exec $CONTAINER_ID wait_all_done 40s
Grab the IP
export HUB_IP=$(docker inspect -f='{{.NetworkSettings.IPAddress}}' $CONTAINER_ID)
Run your tests
protractor testApp/protractor.conf.js

Related

Protractor : Getting 'No Such Context Found' after launching a Hybrid app on mobile emulator

I am trying to run protractor tests by launching a Hybrid app on a mobile emulator. My app is getting launched but then it is getting closed with the error message: 'WebDriverError: No such context found'.
I tried implementing 'setWebContentsDebuggingEnabled : true' from GitHub but this also didn't work. I searched everywhere and asked everyone but no one has the solution to this. I am pretty new to Protractor so any info on this is really helpful.
Environment details:
appium version : 1.6.5
Android Studio : 2.3.3
emulator : Nexus 5X API 24 (Android 7)
Error message when running the test without 'autoWebView:true': Unable
to start a WebDriver session. Error message when running the test
with 'autoWebView:true': WebDriverError: No such context found.
Here is my conf.js file :
exports.config = {
seleniumAddress: 'http://localhost:4723/wd/hub',
capabilities: {
browserName: '',
'appium-version': '1.6.5',
platformName: 'Android',
platformVersion: '7.0',
deviceName: 'Android Emulator',
autoWebview: 'true',
autoWebviewTimeout: '10000',
setWebContentsDebuggingEnabled:'true'
app: 'C://Users//ss//AppData//Local//Android//sdk//platform-tools//WM.apk',
},
baseUrl: 'http://10.0.2.2:8000',
specs: ['basic_spec.js'],
framework: 'jasmine2',
jasmineNodeOpts: {
defaultTimeoutInterval: 120000,
},
};

"Unable to connect to renderer" after upgrade to protractor 4.0.9. Tests won't run. Any ideas as to why?

I had been happily using protractor 3.3.0 with chromedriver 2.21 until Chrome version 54 broke it. I updated to protractor 4.0.9 with chromedriver 2.24 as recommended by the interwebs and now I can't get protractor to run my tests. It looks like it'll start up, flashing a browser window and then throwing this...
Stack trace:
[09:51:27] I/direct - Using ChromeDriver directly...
[09:51:27] I/launcher - Running 1 instances of WebDriver
[09:51:28] E/launcher - session not created exception
from disconnected: unable to connect to renderer
(Session info: chrome=54.0.2840.71)
(Driver info: chromedriver=2.24.417412 (ac882d3ce7c0d99292439bf3405780058fcca0a6),platform=Mac OS X 10.12.0 x86_64)
[09:51:28] E/launcher - SessionNotCreatedError: session not created exception
from disconnected: unable to connect to renderer
(Session info: chrome=54.0.2840.71)
(Driver info: chromedriver=2.24.417412 (ac882d3ce7c0d99292439bf3405780058fcca0a6),platform=Mac OS X 10.12.0 x86_64)
at WebDriverError (/Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:27:10)
at SessionNotCreatedError (/Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:308:10)
at Object.checkLegacyResponse (/Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/error.js:639:15)
at parseHttpResponse (/Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:538:13)
at /Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:472:11
at ManagedPromise.invokeCallback_ (/Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:1379:14)
at TaskQueue.execute_ (/Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2913:14)
at TaskQueue.executeNext_ (/Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2896:21)
at /Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:2820:25
at /Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/promise.js:639:7
From: Task: WebDriver.createSession()
at Function.createSession (/Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver.js:329:24)
at Driver (/Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/node_modules/selenium-webdriver/chrome.js:778:38)
at Direct.getNewDriver (/Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/built/driverProviders/direct.js:68:26)
at Runner.createBrowser (/Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/built/runner.js:198:43)
at /Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/built/runner.js:277:30
at _fulfilled (/Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/node_modules/q/q.js:796:13)
at /Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/node_modules/q/q.js:556:49
at runSingle (/Users/gregorybuchanan/.nvm/versions/node/v4.2.6/lib/node_modules/protractor/node_modules/q/q.js:137:13)
[09:51:28] E/launcher - Process exited with error code 199
I can't find anything referencing this problem...Any ideas?
macOS Sierra
Chrome 54
Protractor 4.0.9
Selenium 2.53.1
Node 4.2.6
My conf.js file:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
framework: 'jasmine2',
suites: {
views: './*_view_spec.js',
forms: './*_form_spec.js',
active: ['./registration_spec.js', './onboarding_spec.js'],
all: './*_spec.js',
current: './registration_spec.js'
},
specs: ['./*_spec.js'],
jasmineNodeOpts: {
showColors: false
},
directConnect: true,
capabilities: {
chromeOptions: {
args: ['--no-sandbox', '--user-data-dir=ProtractorTestProfile','--prompt-for-external-extensions=false', '--load-extension=extension-debug/development/chrome']
},
browserName: 'chrome'
},
params: {
environment: {
api: 'dev',
baseUrl: 'http://webapp-dev.xxxxxxx.com/#/'
}
},
onPrepare: function() {
browser.driver.manage().window().setSize(1280, 1024);
var disableNgAnimate = function() {
angular.module('disableNgAnimate', []).run(['$animate', function($animate) {
$animate.enabled(false);
}]);
};
browser.addMockModule('disableNgAnimate', disableNgAnimate);
browser.getCapabilities().then(function(caps) {
browser.params.browser = caps.get('browserName');
});
}
};
I had the same problem and it turns out that the problem was with my /etc/hosts file. I had
#<ip-address> <hostname.domain.org> <hostname>
127.0.0.1 localhost.localdomain hostname
::1 localhost.localdomain hostname
when it was supposed to be
#<ip-address> <hostname.domain.org> <hostname>
127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost
so the Selenium server thought that you were connecting to it from a remote address or something and blocked the connection.
That's also probably why a fresh reinstall of macOS fixed the problem for you.
Hopefully this helps somebody looking at this in the future!
How have you updated the chrome driver? By using:
webdriver-manager update --versions.chrome 2.24 ?
I had this exactly same issue and I resolved by downloading the chrome driver version from http://chromedriver.storage.googleapis.com/index.html?path=2.24/ extracting the file into my selenium folder (/usr/local/lib/node_modules/webdriver-manager/selenium/) and removing the old one.
I believe there is some error with updating chrome driver using command lines, see: https://github.com/angular/webdriver-manager/issues/102
I couldn't figure this out and couldn't burn anymore time trying. A complete/fresh install of macOS did the trick.
I had the same issue, and reset the hosts, then clear the socket by using
chrome://net-internals/#sockets
That would do the trick.
It's not a selenium or a webdriver problem, just some thing to do with the chrome socket/host buffering.
I came here with the same issue. One day I was running tests just fine, the other day I turned on the IDE, ran the tests again, and it spat out this error. I stumbled upon a solution when I killed Chrome, ChromeDriver, and Eclipse processes, copied a version of Chrome driver that I randomly picked form the repo, then restarted them all and it started working again for some reason. I unfortunately have no idea about the root of this problem.
I am seeing the same issue on Chrome: Version 62.0.3202.75 (Official Build) (64-bit) and ChromeDriver Version: 2.32. I just followed these steps and I am able to run my tests successfully
If you are using browser.manage().window().maximize(); or anything with browser.manage() in your page objects or tests, try to remove them and use the chrome capabilities in protractor.conf.js.
Here is an Example:
capabilities: {
browserName: 'chrome',
chromeOptions: {
// binary: 'PATH/To/your/binary',
args: [
'--disable-infobars', "--disable-gpu", "--start-maximized", '--disable-extensions'
],
prefs: {
// disable chrome's annoying password manager
'profile.password_manager_enabled': false,
'credentials_enable_service': false,
'password_manager_enabled': false
}
}
}

Chromedriver works manually but fails when ran from Jenkins Slave

I have a Jenkins slave node setup with LinuxMint. So we can do some browser testing on a Linux box in Chrome and Firefox.
I have the latest Chromedriver installed where the test can run it and when I go into /var/jenkins/workspace/<project name>/TestAutomation/SeleniumFramework manually and do my run npm <test name> the tests launch the chromedriver and run successfully.
When I go into Jenkins and run my test chromedriver is failing with the following and I am not sure where to go with this.:
Using ChromeDriver directly...
[launcher] Running 1 instances of WebDriver
/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/atoms/error.js:108
var template = new Error(this.message);
^
UnknownError: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.21.371461 (633e689b520b25f3e264a2ede6b74ccc23cb636a),platform=Linux 3.19.0-32-generic x86_64)
at new bot.Error (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/atoms/error.js:108:18)
at Object.bot.response.checkResponse (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/atoms/response.js:109:9)
at /var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:160:24
at promise.ControlFlow.runInFrame_ (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:1857:20)
at goog.defineClass.notify (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:2448:25)
at promise.Promise.notify_ (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:564:12)
at Array.forEach (native)
at promise.Promise.notifyAll_ (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/goog/../webdriver/promise.js:553:15)
at goog.async.run.processWorkQueue (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/goog/async/run.js:130:15)
at process._tickCallback (internal/process/next_tick.js:103:7)
From: Task: WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22)
at Function.webdriver.WebDriver.createSession (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30)
at new Driver (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/selenium-webdriver/chrome.js:810:36)
at DirectDriverProvider.getNewDriver (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/protractor/lib/driverProviders/direct.js:68:16)
at Runner.createBrowser (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/protractor/lib/runner.js:182:37)
at /var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/protractor/lib/runner.js:263:21
at _fulfilled (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/q/q.js:797:54)
at self.promiseDispatch.done (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/q/q.js:826:30)
at Promise.promise.promiseDispatch (/var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/q/q.js:759:13)
at /var/jenkins/workspace/QA-E2E-Linux/TestAutomation/SeleniumFramework/node_modules/q/q.js:525:49
[launcher] Process exited with error code 1
First Solution:
Have you java 8 installed? If yes, uninstall it and install java 7.
Second Solution:
Downgrade protractor to v1.8.0
~
More informations: https://github.com/angular/protractor/issues/1905
#edit
I found a similar topic as your, the same error in jenkins - linux:
In you jenkins settings add a global property
key : DISPLAY
value:0:0
On your server start Xvfb in the background:
Xvfb :0 -ac -screen 0 1024x768x24 &
link: unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.9
So I was connecting to the slaves from the Jenkins master via SSH. This wasn't ever going to launch a browser session. I switched over to the Java Web Start option, and it launched the browser just fine.

Trouble setting up karma-cordova (Linux)

First time doing anything on karma or linux so forgive me if I have made an obvious mistake.
Trying to run basic tests on karma-jasmine using cordova.
On karma start I get the following error logs:
30 10 2015 17:33:28.644:WARN [karma]: No captured browser, open http://localhost:9876/
30 10 2015 17:33:28.651:INFO [karma]: Karma v0.13.14 server started at http://localhost:9876/
using settings: { platforms: [ 'android', 'ios' ],
mode: 'emulate',
hostip: '10.0.2.2',
target: '0468de2a213eae29',
plugins: [ 'org.apache.cordova.console' ] }
30 10 2015 17:33:28.654:INFO [launcher]: Starting browser undefined on Cordova
30 10 2015 17:33:28.655:ERROR [launcher]: [TypeError: Object undefined on Cordova has no method 'on']
TypeError: Object undefined on Cordova has no method 'on'
at /home/phil/node_modules/karma/lib/launcher.js:94:17
at next (/home/phil/node_modules/karma/node_modules/batch/index.js:118:7)
at Batch.end (/home/phil/node_modules/karma/node_modules/batch/index.js:154:5)
at launch (/home/phil/node_modules/karma/lib/launcher.js:110:11)
at invoke (/home/phil/node_modules/karma/node_modules/di/lib/injector.js:75:15)
at Server.<anonymous> (/home/phil/node_modules/karma/lib/server.js:170:24)
at Server.g (events.js:180:16)
at Server.emit (events.js:92:17)
at net.js:1056:10
at process._tickCallback (node.js:448:13)
[spawn] stdout: Fetching plugin "org.apache.cordova.console" via npm
[spawn] stdout: WARNING: org.apache.cordova.console has been renamed to cordova-plugin-console. You may not be getting the latest version! We suggest youcordova plugin rm org.apache.cordova.consoleandcordova plugin add cordova-plugin-console.
Fetching plugin "org.apache.cordova.console" via cordova plugins registry
[spawn] stdout: Plugin "org.apache.cordova.console" already installed on android.
[spawn] stdout: Plugin "org.apache.cordova.console" already installed on ios.
[spawn] stderr: Platform android already added.
[spawn] stdout: WARNING: Applications for platform ios can not be built on this OS - linux.
[spawn] stderr: Platform ios already added.
Done adding platforms
[spawn] stdout: Running command: /tmp/cordova_test/platforms/android/cordova/build
[spawn] stderr: [Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]
[spawn] stdout: ERROR building one of the platforms: Error: /tmp/cordova_test/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
[spawn] stderr: Error: /tmp/cordova_test/platforms/android/cordova/build: Command failed with exit code 2
at ChildProcess.whenDone (/root/.nvm/v0.10.40/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:766:16)
at Process.ChildProcess._handle.onexit (child_process.js:833:5)
30 10 2015 17:33:34.455:ERROR [launcher.cordova]: "cordova build" failed with code 1
Below is my karma.conf.js file:
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
'*.js',
'test/test1/test1.js'
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preproces sor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WAR N || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file chan ges
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launc her
browsers: ['Cordova'],
cordovaSettings: {
platforms:['android', 'ios'],
mode: 'emulate',
hostip: '10.0.2.2',
target :'0468de2a213eae29',
plugins: ['org.apache.cordova.console']
},
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
plugins: [
'karma-cordova-launcher',
'karma-jasmine',
'karma-cordova-launcher'
],
// Concurrency level
// how many browser should be started simultanous
concurrency: Infinity
})
}
Any advice appreciated, cheers!
Seems that the user running karma has not set the ANDROID_HOME environment variable.
Try opening the terminal and typing:
export ANDROID_HOME=/path/to/your/android/sdk
export PATH=$PATH:$ANDROID_HOME/bin
You can also add those lines to the user .bashrc to load them in each login.

Uncaught object error with Karma

I am pretty new to jasmine and karma, but I have a rails app set up using requirejs and jasmine and I'm trying to get karma up and running. I have it running, but when I run the unit.js config file, I get the following error.
INFO [karma]: Karma v0.12.16 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 35.0.1916 (Linux)]: Connected on socket PFOOqf9ZbOB_Tv7zhugx with id 60346244
Chrome 35.0.1916 (Linux) ERROR
Uncaught object
at /home/parallels/Code/Test/src/node_modules/requirejs/require.js:141
WARN [web-server]: 404: /people.js
WARN [web-server]: 404: /jquery.js
WARN [web-server]: 404: /page.js
WARN [web-server]: 404: /dropzone.js
Line 141 in require.js is
function defaultOnError(err) {
throw err; //<-- this is 141
}
Here is my karma unit.js config file.
// Karma configuration
// Generated on Thu Jul 10 2014 08:25:37 GMT-0400 (EDT)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '../../..',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine', 'requirejs'],
// list of files / patterns to load in the browser
files: [
{ pattern: 'spec/javascripts/extensions/*_spec.js', included: true },
{ pattern: 'spec/javascripts/*_spec.js', included: true }
],
// list of files to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
});
};
I'm not sure what the problem is, but based on the 404 messages, I'm guessing it might have something to do with requirejs not being able to find those 4 javascript files. If I manually run my jasmine specs they all run fine, so I'm not quite sure where/why it's breaking down. Anyone have any ideas? Thanks.
Edit:
I have updated my code based on the karma+requireJS documentation. It seems like it's gotten me further along, but now I just get a generic error without much of a message to know what's going on.
When I run the karma test I get this....
karma start spec/karma/config/unit.js
INFO [karma]: Karma v0.12.16 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 35.0.1916 (Linux)]: Connected on socket OwrWtfnBJ4zB6DERU0cI with id 70596022
Chrome 35.0.1916 (Linux): Executed 0 of 0 ERROR (0.004 secs / 0 secs)
My folder structure is as follows
src
--app
----assets
------javascripts
--------application.js, global.js,page.js, routes.js, people.js, etc
--spec
----javascripts
------*_spec.js
----karma
------config
--------unit.js, test-main.js
--vendor
----assets
------javascripts
--------dropzone.js, icheck.js, jquery-ui.js, mustache.js

Resources