Last active
June 18, 2017 13:26
-
-
Save thomassuckow/6372324 to your computer and use it in GitHub Desktop.
Using karma to load requirejs tests with the .spec.js suffix. Note the base url needs the / otherwise karma-requirejs will whine about no timestamp (paths will differ) We mangle the files list to be relative, otherwise using relative paths in the form of "./bar" will fail. In my use case I have a shared config.js file that has more configuration…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tests = Object.keys(window.__karma__.files).filter(function (file) { | |
return /\.spec\.js$/.test(file); | |
}).map(function(file){ | |
return file.replace(/^\/base\/src\/js\/|\.js$/g,''); | |
}); | |
require.config({ | |
baseUrl: '/base/src/js', | |
paths: { | |
"lib":"../../target/js/lib" | |
} | |
}); | |
require(['config'],function(){ | |
require(tests, function(){ | |
window.__karma__.start(); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tests = Object.keys(window.__karma__.files).filter(function (file) { | |
return /\.spec\.js$/.test(file); | |
}).map(function(file){ | |
return file.replace(/^\/base\/src\/js\/|\.js$/g,''); | |
}); | |
require.config({ | |
baseUrl: '/base/src/js' | |
}); | |
require(tests, function(){ | |
window.__karma__.start(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks so much! This really helped me get my Karma/Require configuration straightened out... After 12 hours of searching.