Running multiple tests properly

2,680 views
Skip to first unread message

Alex Casanova

unread,
Jun 14, 2013, 10:33:32 AM6/14/13
to karma...@googlegroups.com
I have a bunch of tests i'd like to run in succession. Im using grunt-karma and I made a task to run everything in karma. The tests run but I get a ton of warnings in console about karma "Port 9877 in use" for each test. The more tests I run the more warnings. I tried changing the runnerPort to the same port for each test but still get these warnings.  Any way to get all the different config files to run in once instance? Excuse my ignorance if that doesn't make sense. 

.....
Running "karma:template" (karma) task
WARN [karma]: Port 9876 in use
WARN [karma]: Port 9999 in use
WARN [karma]: Port 9877 in use
WARN [karma]: Port 10000 in use
WARN [karma]: Port 9878 in use
WARN [karma]: Port 10001 in use
WARN [karma]: Port 9879 in use
WARN [karma]: Port 10002 in use
WARN [karma]: Port 9880 in use
WARN [karma]: Port 10003 in use
WARN [karma]: Port 9881 in use
WARN [karma]: Port 10004 in use
WARN [karma]: Port 9882 in use
WARN [karma]: Port 10005 in use
WARN [karma]: Port 9883 in use
WARN [karma]: Port 10006 in use
INFO [karma]: Karma server started at http://localhost:9884/
INFO [launcher]: Starting browser Chrome
INFO [karma]: To run via this server, use "karma run --runner-port 10007"
INFO [Chrome 27.0 (Mac)]: Connected on socket id Ip2oTafehC5or_nfCNQz
Chrome 27.0 (Mac): Executed 0 of 0 SUCCESS (0.085 secs / 0 secs)
.....




Vojta Jína

unread,
Jun 14, 2013, 7:57:13 PM6/14/13
to karma...@googlegroups.com
You are getting the warnings, because you are starting multiple isntances of karma.

Why do you need multiple config files ? Typically you have a single config per project and that runs all the tests.

V.


--
You received this message because you are subscribed to the Google Groups "karma-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to karma-users...@googlegroups.com.
To post to this group, send email to karma...@googlegroups.com.
Visit this group at http://groups.google.com/group/karma-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Alex Casanova

unread,
Jun 14, 2013, 8:43:47 PM6/14/13
to karma...@googlegroups.com
I guess you're right. Theres multiple different parts of this app and thought it maybe easier for the different developers to have separate configs for the parts they coded.

Vojta Jína

unread,
Jun 17, 2013, 11:41:32 AM6/17/13
to karma...@googlegroups.com
Yep. You can even have config per subproject and one "main" that contains all of them.

Alex Casanova

unread,
Jun 17, 2013, 12:13:18 PM6/17/13
to karma...@googlegroups.com
So you are saying I can have one main config that reads the other configs?

Vojta Jína

unread,
Jun 18, 2013, 11:31:14 PM6/18/13
to karma...@googlegroups.com
Yep, you can "require" other configs. Especially with 0.9 (currently only at canary release channel), the config is a regular node module and you can easily combine multiple configs (eg. you can have some default config as a user and then load that config in each project)

V.

Alex Casanova

unread,
Jun 20, 2013, 11:01:07 AM6/20/13
to karma...@googlegroups.com
I'm sorry that last reply confuses me. Do you have an example I can see of this?

Vojta Jína

unread,
Jun 23, 2013, 8:20:28 PM6/23/13
to karma...@googlegroups.com
With karma 0.8 (current stable)

// shared_conf.js
module.exports = {
  port: 8080
};

// karma1.conf.js
var shared = require('./shared_conf.js');

port = shared.port;


With karma 0.9 (currently in canary release):

// shared_conf.js
module.exports = function(karma) {
  karma.configure({
    port: 8080  
  });
};

// karma1.conf.js
var shared = require('./shared_conf.js');
module.exports = function(karma) {
  shared(karma);
  karma.configure({
    // override
  });
};


Hope this helps,
V.

cbi...@gmail.com

unread,
Aug 7, 2013, 11:46:50 AM8/7/13
to karma...@googlegroups.com
Hi Vojta!

Do we put this shared_conf.js in the same folder as the karma config files? I keep getting an error saying:

ERROR [config]: Invalid config file!
 { [Error: Cannot find module './shared.conf.js'] code: 'MODULE_NOT_FOUND' }
Error: Cannot find module './shared.conf.js'

I also tried putting that shared config file in my node_modules folder and in the root of the project. Also tried changing the path in require();

Vojta Jína

unread,
Aug 8, 2013, 12:23:16 AM8/8/13
to karma...@googlegroups.com
This is just Node.js - nothing Karma specific, you can read http://nodejs.org/api/modules.html
require('./shared.conf.js') should load file from the same folder as the source file.

V.
Reply all
Reply to author
Forward
0 new messages