2018-11-08 05:33:43 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 - present Instructure, Inc.
|
|
|
|
*
|
|
|
|
* This file is part of Canvas.
|
|
|
|
*
|
|
|
|
* Canvas is free software: you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU Affero General Public License as published by the Free
|
|
|
|
* Software Foundation, version 3 of the License.
|
|
|
|
*
|
|
|
|
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
|
|
* details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2017-03-09 04:58:38 +08:00
|
|
|
const karmaConfig = {
|
2015-10-01 11:16:11 +08:00
|
|
|
basePath: '',
|
|
|
|
|
|
|
|
frameworks: ['qunit'],
|
|
|
|
|
|
|
|
proxies: {
|
2017-08-09 07:22:05 +08:00
|
|
|
'/dist/brandable_css/': '/base/public/dist/brandable_css/',
|
|
|
|
'/images/': '/base/public/images/'
|
2015-10-01 11:16:11 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
exclude: [],
|
|
|
|
|
|
|
|
// 'dots', 'progress', 'junit', 'growl', 'coverage', 'spec'
|
2017-12-18 23:21:42 +08:00
|
|
|
reporters: ['spec', 'junit'],
|
2017-02-14 11:57:26 +08:00
|
|
|
// enable the verbose reporter if you want to have more information of where/how specs fail
|
|
|
|
// reporters: ['verbose'],
|
|
|
|
|
2017-12-18 23:21:42 +08:00
|
|
|
// this is to make a nice "spec failures" report in the jenkins build instead of having to look at the log output
|
|
|
|
junitReporter: {
|
2017-12-22 04:09:17 +08:00
|
|
|
outputDir: 'coverage-js/junit-reports',
|
|
|
|
outputFile: `karma-${process.env.JSPEC_GROUP || 'all'}.xml`,
|
|
|
|
useBrowserName: false, // don't add browser name to report and classes names
|
2017-12-18 23:21:42 +08:00
|
|
|
},
|
|
|
|
specReporter: {
|
|
|
|
maxLogLines: 50, // limit number of lines logged per test
|
|
|
|
suppressErrorSummary: false, // print error summary
|
|
|
|
showSpecTiming: true, // print the time elapsed for each spec
|
|
|
|
},
|
|
|
|
|
2015-10-01 11:16:11 +08:00
|
|
|
port: 9876,
|
|
|
|
|
|
|
|
colors: true,
|
|
|
|
|
|
|
|
autoWatch: true,
|
|
|
|
|
|
|
|
// - Chrome
|
|
|
|
// - ChromeCanary
|
2017-08-16 00:17:33 +08:00
|
|
|
// - ChromeHeadless
|
2015-10-01 11:16:11 +08:00
|
|
|
// - Firefox
|
|
|
|
// - Opera (has to be installed with `npm install karma-opera-launcher`)
|
|
|
|
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
|
2017-11-01 01:25:38 +08:00
|
|
|
// - PhantomJS (has to be installed with `npm install karma-phantomjs-launcher`))
|
2015-10-01 11:16:11 +08:00
|
|
|
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
|
2018-10-22 23:06:57 +08:00
|
|
|
browsers: ['ChromeWithoutBackground'],
|
2015-10-01 11:16:11 +08:00
|
|
|
|
2017-08-16 00:17:33 +08:00
|
|
|
customLaunchers: {
|
2018-10-22 23:06:57 +08:00
|
|
|
// Chrome will sometimes be in the background when specs are running,
|
|
|
|
// leading to different behavior with things like event propagation, which
|
|
|
|
// leads easily to bugs in production and/or spec code. To decrease the
|
|
|
|
// chances of this, render backgrounding must be disabled when launching
|
|
|
|
// Chrome.
|
|
|
|
ChromeWithoutBackground: {
|
|
|
|
base: 'Chrome',
|
|
|
|
flags: ['--disable-renderer-backgrounding']
|
|
|
|
},
|
|
|
|
|
|
|
|
// Run headless chrome with `karma start --browsers ChromeHeadlessNoSandbox`
|
2017-08-16 00:17:33 +08:00
|
|
|
ChromeHeadlessNoSandbox: {
|
|
|
|
base: 'ChromeHeadless',
|
2018-10-22 23:06:57 +08:00
|
|
|
flags: ['--no-sandbox', '--disable-renderer-backgrounding'] // needed for running tests in local docker
|
2017-08-16 00:17:33 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-10-01 11:16:11 +08:00
|
|
|
// If browser does not capture in given timeout [ms], kill it
|
|
|
|
captureTimeout: 60000,
|
|
|
|
|
2016-10-19 01:11:26 +08:00
|
|
|
browserNoActivityTimeout: 2000000,
|
2016-06-07 04:03:40 +08:00
|
|
|
|
2017-02-14 11:57:26 +08:00
|
|
|
reportSlowerThan: 1000,
|
|
|
|
|
|
|
|
// normally QUnit wraps each test in a try/catch so a single spec failing
|
|
|
|
// doesn't stop the whole test suite. In dev, if you want to click the
|
|
|
|
// "pause on exception" thing in chrome and have it stop on your failing test, enable notrycatch
|
|
|
|
// client: {qunit: {notrycatch: true}},
|
|
|
|
|
|
|
|
// by default we keep the browser open so it refreshes with any changes
|
|
|
|
// but in `npm test` (which is what jenkins CI runs) we override it so
|
|
|
|
// it just runs once and then exits.
|
2017-03-09 04:58:38 +08:00
|
|
|
singleRun: false,
|
2017-02-14 11:57:26 +08:00
|
|
|
|
|
|
|
files: [
|
|
|
|
{pattern: 'spec/javascripts/webpack_spec_index.js', included: true, served: true},
|
|
|
|
{pattern: 'spec/javascripts/fixtures/*', included: false, served: true},
|
|
|
|
{pattern: 'public/dist/brandable_css/**/*.css', included: false, served: true},
|
|
|
|
],
|
|
|
|
|
|
|
|
preprocessors: {
|
|
|
|
'spec/javascripts/webpack_spec_index.js': ['webpack']
|
|
|
|
},
|
|
|
|
|
|
|
|
webpack: require('./webpack.test.config'),
|
2017-03-09 04:58:38 +08:00
|
|
|
}
|
2015-10-01 11:16:11 +08:00
|
|
|
|
2017-08-15 07:07:13 +08:00
|
|
|
// For faster local debugging in karma, only add istanbul cruft you've explicity set the "COVERAGE" environment variable
|
|
|
|
if (process.env.COVERAGE) {
|
|
|
|
karmaConfig.reporters.push('coverage-istanbul')
|
|
|
|
karmaConfig.coverageIstanbulReporter = {
|
2018-04-06 05:27:42 +08:00
|
|
|
reports: ['html', 'json'],
|
|
|
|
dir: 'coverage-karma/',
|
2017-08-15 07:07:13 +08:00
|
|
|
fixWebpackSourcePaths: true
|
|
|
|
}
|
|
|
|
karmaConfig.webpack.module.rules.unshift({
|
|
|
|
test: /\.(js|coffee)$/,
|
|
|
|
use: {
|
|
|
|
loader: 'istanbul-instrumenter-loader',
|
2018-04-06 05:27:42 +08:00
|
|
|
options: { esModules: true, produceSourceMap: true }
|
2017-08-15 07:07:13 +08:00
|
|
|
},
|
|
|
|
enforce: 'post',
|
|
|
|
exclude: /(node_modules|spec|public\/javascripts\/(bower|client_apps|translations|vendor|custom_moment_locales|custom_timezone_locales))/,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-02-09 14:52:26 +08:00
|
|
|
module.exports = function (config) {
|
2015-10-01 11:16:11 +08:00
|
|
|
// config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
2017-03-09 04:58:38 +08:00
|
|
|
karmaConfig.logLevel = config.LOG_INFO
|
2017-02-09 14:52:26 +08:00
|
|
|
config.set(karmaConfig)
|
|
|
|
}
|