upgrade to karma 1.1.1

this was a blocker for upgrading to node 6 since
karma 0.x has a strict node version requirement
of <=4, so it would not work on node 6 (although, 
ironically, if you forced it it would still work)

closes: CNVS-30308

test plan:
* run `npm install && bundle exec rake js:test`
* it should work
* the jenkins builds should all work


Change-Id: Ifd9ae12347d7901cf2bafee110230699987b2511
Reviewed-on: https://gerrit.instructure.com/84590
Tested-by: Jenkins
Reviewed-by: Matthew Sessions <msessions@instructure.com>
Product-Review: Ryan Shaw <ryan@instructure.com>
QA-Review: Ryan Shaw <ryan@instructure.com>
This commit is contained in:
Ryan Shaw 2016-07-07 15:01:53 -06:00
parent 61eb8e3d33
commit 92357a7a60
4 changed files with 36 additions and 37 deletions

View File

@ -1,5 +1,4 @@
var fs = require("fs");
var karmaFiles = [];
var webpackFileExists = false;
var webpackFilePath = __dirname + "/config/WEBPACK";
@ -16,7 +15,8 @@ var usingWebpack = (process.env.USE_WEBPACK == 'True' ||
webpackFileExists);
// If we're using webpack, we don't want to load all the requirejs stuff;
if(usingWebpack){
var karmaFiles;
if (usingWebpack) {
karmaFiles = [
'spec/javascripts/support/sinon/sinon-1.17.2.js',
'spec/javascripts/support/axe.js',

View File

@ -129,7 +129,10 @@ namespace :js do
end
puts "--> executing browser tests with Karma"
build_runner
system "./node_modules/karma/bin/karma start --browsers Chrome --single-run --reporters progress,#{reporter}"
reporters = ['progress', reporter].reject(&:blank?).join(',')
command = %Q{./node_modules/karma/bin/karma start --browsers Chrome --single-run --reporters #{reporters}}
puts "running karma with command: #{command} on node #{`node -v`}"
system command
if $?.exitstatus != 0
puts 'some specs failed'

View File

@ -34,12 +34,12 @@
"js-yaml": "^3.4.3",
"json-loader": "^0.5.3",
"jsx-loader": "0.11.2",
"karma": "~0.13.0",
"karma-chrome-launcher": "^0.2.0",
"karma": "1.1.1",
"karma-chrome-launcher": "^1.0.1",
"karma-firework-reporter": "~0.2.4",
"karma-phantomjs-launcher": "^1.0.0",
"karma-qunit": "~0.1.1",
"karma-requirejs": "^0.2.2",
"karma-qunit": "~1.1.0",
"karma-requirejs": "^1.0.0",
"karma-webpack": "^1.7.0",
"lodash": "^3.10.1",
"on-build-webpack": "^0.1.0",

View File

@ -1,41 +1,37 @@
tests = __TESTS__;
// tests = tests.slice(0,50);
// console.log(tests);
var thingsToLoadWithRequireJS = []
var TEST_REGEXP = /^\/base\/spec\/.*Spec\.js$/i
tests = tests.map(function(test) {
return test.indexOf('spec/javascripts') === 0 ? '../../' + test : test;
});
// Get a list of all the test files to include
Object.keys(window.__karma__.files).forEach(function (file) {
if (TEST_REGEXP.test(file)) {
// Normalize paths to RequireJS module names so it works with our `baseUrl` below
// eg: converts '/base/spec/javascripts/fooSpec.js' to '../../spec/javascripts/fooSpec'
var normalizedTestModule = file
.replace(/^\/base\//, '../../')
.replace(/\.js$/, '')
thingsToLoadWithRequireJS.push(normalizedTestModule)
}
})
// include the english translations by default, same as would happen in
// production via common.js. this saves the test writer from having to stub
// translations anytime they need to use code that uses a no-default
// translation call (e.g. I18n.t('#date.formats.medium')) with the default
// locale
tests.push('translations/_core_en');
thingsToLoadWithRequireJS.push('translations/_core_en')
window.addEventListener("DOMContentLoaded",function() {
if(!document.getElementById('fixtures')) {
var fixturesDiv = document.createElement('div');
fixturesDiv.id = 'fixtures';
document.body.appendChild(fixturesDiv);
window.addEventListener("DOMContentLoaded", function() {
if (!document.getElementById('fixtures')) {
var fixturesDiv = document.createElement('div')
fixturesDiv.id = 'fixtures'
document.body.appendChild(fixturesDiv)
}
},false);
}, false)
if(!window.ENV) window.ENV = {};
if(!window.ENV) window.ENV = {}
if(window.__karma__) {
requirejs.config({
baseUrl: '/base/public/javascripts',
deps: tests,
callback: window.__karma__.start
});
} else {
QUnit.config.autostart = false;
requirejs.config({
baseUrl: '/public/javascripts',
deps: tests,
callback: function() {
QUnit.start();
}
});
}
requirejs.config({
baseUrl: '/base/public/javascripts',
deps: thingsToLoadWithRequireJS, // dynamically load all test files
callback: window.__karma__.start
});