Blame view

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