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.
Related
All our tests pass on multiple macOS machines, and on semaphore-ci, but when we try to build and run tests on a new debian box, we get this error in loader.js:143
not ok 1320 Chrome 72.0 - TestLoader Failures: zipbooks/tests/unit/utils/request-log-test: could not be loaded
---
actual: >
null
stack: >
TypeError: Cannot read property 'exports' of undefined
at Module._reify (http://localhost:45371/assets/vendor.js:148:59)
at Module.reify (http://localhost:45371/assets/vendor.js:135:27)
at Module.exports (http://localhost:45371/assets/vendor.js:109:10)
at Module._reify (http://localhost:45371/assets/vendor.js:148:59)
at Module.reify (http://localhost:45371/assets/vendor.js:135:27)
at Module.exports (http://localhost:45371/assets/vendor.js:109:10)
at Module._reify (http://localhost:45371/assets/vendor.js:148:59)
at Module.reify (http://localhost:45371/assets/vendor.js:135:27)
at Module.exports (http://localhost:45371/assets/vendor.js:109:10)
at requireModule (http://localhost:45371/assets/vendor.js:32:18)
message: >
Died on test #1 at TestLoader.moduleLoadFailure (http://localhost:45371/assets/test-support.js:11150:24)
at TestLoader.<anonymous> (http://localhost:45371/assets/test-support.js:10463:16)
at TestLoader.require (http://localhost:45371/assets/test-support.js:10451:27)
at TestLoader.loadModules (http://localhost:45371/assets/test-support.js:10443:16)
at loadTests (http://localhost:45371/assets/test-support.js:11174:22)
at start (http://localhost:45371/assets/test-support.js:10857:33)
at Module.callback (http://localhost:45371/assets/tests.js:20710:25): Cannot read property 'exports' of undefined
Log: |
{ type: 'info',
text: '\'Unit assertion failed and test has been paused for inspection.\'\n' }
{ type: 'error',
text: '{ module: \'TestLoader Failures\',\n name: \'zipbooks/tests/unit/utils/request-log-test: could not be loaded\',\n result: false,\n message: \'Died on test #1 at TestLoader.moduleLoadFailure (http://localhost:45371/assets/test-support.js:11150:24)\\n at TestLoader.<anonymous> (http://localhost:45371/assets/test-support.js:10463:16)\\n at TestLoader.require (http://localhost:45371/assets/test-support.js:10451:27)\\n at TestLoader.loadModules (http://localhost:45371/assets/test-support.js:10443:16)\\n at loadTests (http://localhost:45371/assets/test-support.js:11174:22)\\n at start (http://localhost:45371/assets/test-support.js:10857:33)\\n at Module.callback (http://localhost:45371/assets/tests.js:20710:25): Cannot read property \\\'exports\\\' of undefined\',\n actual: null,\n testId: \'8629d10a\',\n negative: false,\n runtime: 1,\n todo: false,\n source: \'TypeError: Cannot read property \\\'exports\\\' of undefined\\n at Module._reify (http://localhost:45371/assets/vendor.js:148:59)\\n at Module.reify (http://localhost:45371/assets/vendor.js:135:27)\\n at Module.exports (http://localhost:45371/assets/vendor.js:109:10)\\n at Module._reify (http://localhost:45371/assets/vendor.js:148:59)\\n at Module.reify (http://localhost:45371/assets/vendor.js:135:27)\\n at Module.exports (http://localhost:45371/assets/vendor.js:109:10)\\n at Module._reify (http://localhost:45371/assets/vendor.js:148:59)\\n at Module.reify (http://localhost:45371/assets/vendor.js:135:27)\\n at Module.exports (http://localhost:45371/assets/vendor.js:109:10)\\n at requireModule (http://localhost:45371/assets/vendor.js:32:18)\' }\n' }
We cannot find any information or have any guesses what might be causing this error.
ember-cli: 3.1.4
node: 8.5.0
os: linux x64
The pattern I'm seeing is that any test that uses setupTest, setupApplicationTest or setupRenderingTest is failing. Regular qunit tests that dont have any setup hooks pass fine.
The problem was not installing the yarn dependencies in our in-repo addon 😑
The most likely cause is binary dependencies that are platform-specific. Have you tried running npm rebuild first? Certain dependencies (such as node-sass) use binaries that are platform-specific, and need to be rebuilt. If that's your issue, if you ever need to do this in an automated fashion, you'll want to limit the scope of the rebuild to only the necessary dependencies, e.g. npm rebuild some-package some-other-package rather than the all inclusive npm rebuild
Unfortunately, yarn has yet to implement the rebuild feature, so we've moved back to npm, for that and other reasons. -- link to issue in GitHub
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
}
}
}
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
I have the below configuration in the karma config file.
frameworks: [
'jasmine',
'requirejs'
],
files: [
//App Bower components
{pattern: 'public/bower_components/**/*', included: false}
.....
// list of files / patterns to exclude
exclude: [
'public/bower_components/**/spec/**/*',
'public/bower_components/**/*spec*.js'
],
with this while running karma, i am getting the below error:
Running "karma:runner" (karma) task
WARN [watcher]: { [Error: EMFILE, readdir '/test-application/public/bower_components/requirejs/tests/commonjs/tests/modules/1.0/absolute/b.js']
errno: 20,
code: 'EMFILE',
path: '/test-application/public/bower_components/requirejs/tests/commonjs/tests/modules/1.0/absolute/b.js' }
Error: EMFILE, readdir '/test-application/public/bower_components/requirejs/tests/commonjs/tests/modules/1.0/absolute/b.js'
Fatal error: Cannot read property 'length' of undefined
I tried to add 'public/bower_components/requirejs/tests//*.js' & 'public/bower_components//tests/**/*.js' in the exclude section but i still get the same error.
Any idea on how to get this working.
The fix for the above seems to be not with karma but with the OSX. I had to do the below
ulimit -n 2560
in my bash_profile to get this to work.
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