Open luisvt opened 8 years ago
The error about the __karma__.start
method is tracked in #2194 and has nothing to do with the behaviour you are looking for. Your second configuration should work fine. Also in general you can easily write a method for the behaviour that you want
function toModule (name) {
return {
pattern: 'node_modules/' + name,
included: false
}
}
// later
files: [
toModule('angular/angular.js'),
toModule('requirejs/require.js'),
toModule('lodash/lodash.js'),
'test-main.js'
}
with karma 1.2.0
having next code in karma.config.js
:
files: [
{pattern: 'node_modules/**/*.js', included: false},
'test-main.js'
}
it produces next error message:
25 08 2016 18:41:32.578:ERROR [karma]: { Error: listen ENFILE 0.0.0.0:9876
at Object.exports._errnoException (util.js:1008:11)
at exports._exceptionWithHostPort (util.js:1031:20)
at Server._listen2 (net.js:1240:19)
at listen (net.js:1289:10)
at Server.listen (net.js:1385:5)
at afterPreprocess (/Users/lvargas/projects/js/angular-typescript/node_modules/karma/lib/server.js:174:15)
at tryCatcher (/Users/lvargas/projects/js/angular-typescript/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/lvargas/projects/js/angular-typescript/node_modules/bluebird/js/release/promise.js:509:31)
at Promise._settlePromise (/Users/lvargas/projects/js/angular-typescript/node_modules/bluebird/js/release/promise.js:566:18)
at Promise._settlePromise0 (/Users/lvargas/projects/js/angular-typescript/node_modules/bluebird/js/release/promise.js:611:10)
at Promise._settlePromises (/Users/lvargas/projects/js/angular-typescript/node_modules/bluebird/js/release/promise.js:686:18)
at Async._drainQueue (/Users/lvargas/projects/js/angular-typescript/node_modules/bluebird/js/release/async.js:138:16)
at Async._drainQueues (/Users/lvargas/projects/js/angular-typescript/node_modules/bluebird/js/release/async.js:148:10)
at Immediate.Async.drainQueues (/Users/lvargas/projects/js/angular-typescript/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:566:20)
at tryOnImmediate (timers.js:546:5)
code: 'ENFILE',
errno: 'ENFILE',
syscall: 'listen',
address: '0.0.0.0',
port: 9876 }
From what I understand it means that Karma Server is trying to open and listen into too many files.
This is because that glob pattern is overly broad.
IMO, that is fine, because a broad glob pattern has huge negative performance implications as well. This is one area where I think supporting has large negative ramifications for the user on the performance side, and that nothing more should be done in karma itself in regards to this area.
Expected behavior
Allow specify a configuration option to be able to serve some directories like
node_modules
andbower_components
as base directories.This should be similar to what (browserSync baseDir)[https://www.browsersync.io/docs/options#option-server] option does. This will allow developers to use npm packages for browser unit-testing.
Actual behavior
Right now we should specify all the files coming from
node_modules
one by one. This is cumbersome. For example if we want to userequirejs
,angular
andlodash
we should do:since trying to use a glob value for node modules doesn't work, for example doing this:
throws next error:
Enviroment Details
karma.config.js
file