1 | 'use strict';
|
---|
2 |
|
---|
3 | var ip = require('ip');
|
---|
4 | var browserConfig = require('./browsers');
|
---|
5 | var browserStack = process.env.BROWSER === 'true';
|
---|
6 |
|
---|
7 | module.exports = function (config) {
|
---|
8 | var conf = {
|
---|
9 | basePath: '../',
|
---|
10 | frameworks: ['qunit'],
|
---|
11 | plugins: ['karma-qunit'],
|
---|
12 | // list of files / patterns to load in the browser
|
---|
13 | files: [
|
---|
14 | 'js/tests/vendor/jquery.min.js',
|
---|
15 | 'js/tooltip.js',
|
---|
16 | 'js/!(tooltip).js',
|
---|
17 | 'js/tests/unit/*.js'
|
---|
18 | ],
|
---|
19 | reporters: ['dots'],
|
---|
20 | port: 9876,
|
---|
21 | colors: true,
|
---|
22 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
---|
23 | logLevel: config.LOG_ERROR || config.LOG_WARN,
|
---|
24 | autoWatch: false,
|
---|
25 | singleRun: true,
|
---|
26 | concurrency: Infinity,
|
---|
27 | client: {
|
---|
28 | qunit: {
|
---|
29 | showUI: true
|
---|
30 | }
|
---|
31 | }
|
---|
32 | };
|
---|
33 |
|
---|
34 | if (browserStack) {
|
---|
35 | conf.hostname = ip.address();
|
---|
36 | conf.browserStack = {
|
---|
37 | username: process.env.BROWSER_STACK_USERNAME,
|
---|
38 | accessKey: process.env.BROWSER_STACK_ACCESS_KEY,
|
---|
39 | build: 'bootstrap-v3-' + new Date().toISOString(),
|
---|
40 | project: 'Bootstrap v3',
|
---|
41 | retryLimit: 1
|
---|
42 | };
|
---|
43 | conf.plugins.push('karma-browserstack-launcher');
|
---|
44 | conf.customLaunchers = browserConfig.list;
|
---|
45 | conf.browsers = browserConfig.keys;
|
---|
46 | conf.reporters.push('BrowserStack');
|
---|
47 | } else {
|
---|
48 | conf.frameworks.push('detectBrowsers');
|
---|
49 | conf.plugins.push(
|
---|
50 | 'karma-chrome-launcher',
|
---|
51 | 'karma-firefox-launcher',
|
---|
52 | 'karma-detect-browsers'
|
---|
53 | );
|
---|
54 |
|
---|
55 | conf.detectBrowsers = {
|
---|
56 | usePhantomJS: false,
|
---|
57 | postDetection: function (availableBrowser) {
|
---|
58 | if (typeof process.env.TRAVIS_JOB_ID !== 'undefined' || availableBrowser.includes('Chrome')) {
|
---|
59 | return ['ChromeHeadless'];
|
---|
60 | }
|
---|
61 |
|
---|
62 | if (availableBrowser.includes('Firefox')) {
|
---|
63 | return ['FirefoxHeadless'];
|
---|
64 | }
|
---|
65 |
|
---|
66 | throw new Error('Please install Firefox or Chrome');
|
---|
67 | }
|
---|
68 | };
|
---|
69 |
|
---|
70 | conf.customLaunchers = {
|
---|
71 | FirefoxHeadless: {
|
---|
72 | base: 'Firefox',
|
---|
73 | flags: ['-headless']
|
---|
74 | }
|
---|
75 | };
|
---|
76 | }
|
---|
77 |
|
---|
78 | config.set(conf);
|
---|
79 | };
|
---|