talos

Форк
0
144 строки · 3.4 Кб
1
/* eslint-env node */
2

3
'use strict'
4

5
const path = require('path')
6
const ip = require('ip')
7
const { browsers, browsersKeys } = require('./browsers')
8

9
const USE_OLD_JQUERY = Boolean(process.env.USE_OLD_JQUERY)
10
const BUNDLE = Boolean(process.env.BUNDLE)
11
const BROWSERSTACK = Boolean(process.env.BROWSERSTACK)
12
const JQUERY_FILE = USE_OLD_JQUERY ?
13
  'https://cdn.jsdelivr.net/npm/jquery@1.9.1/jquery.min.js' :
14
  'node_modules/jquery/dist/jquery.slim.min.js'
15

16
const frameworks = [
17
  'qunit',
18
  'sinon'
19
]
20

21
const plugins = [
22
  'karma-qunit',
23
  'karma-sinon'
24
]
25

26
const reporters = ['dots']
27

28
const detectBrowsers = {
29
  usePhantomJS: false,
30
  postDetection(availableBrowser) {
31
    // On CI just use Chrome
32
    if (process.env.CI === true) {
33
      return ['ChromeHeadless']
34
    }
35

36
    if (availableBrowser.includes('Chrome')) {
37
      return ['ChromeHeadless']
38
    }
39

40
    if (availableBrowser.includes('Chromium')) {
41
      return ['ChromiumHeadless']
42
    }
43

44
    if (availableBrowser.includes('Firefox')) {
45
      return ['FirefoxHeadless']
46
    }
47

48
    throw new Error('Please install Chrome, Chromium or Firefox')
49
  }
50
}
51

52
let files = [
53
  'node_modules/popper.js/dist/umd/popper.min.js',
54
  'node_modules/hammer-simulator/index.js'
55
]
56

57
const conf = {
58
  basePath: '../..',
59
  port: 9876,
60
  colors: true,
61
  autoWatch: false,
62
  singleRun: true,
63
  concurrency: Infinity,
64
  client: {
65
    qunit: {
66
      showUI: true
67
    }
68
  }
69
}
70

71
if (BUNDLE) {
72
  frameworks.push('detectBrowsers')
73
  plugins.push(
74
    'karma-chrome-launcher',
75
    'karma-firefox-launcher',
76
    'karma-detect-browsers'
77
  )
78
  conf.detectBrowsers = detectBrowsers
79
  files = [...files,
80
    JQUERY_FILE,
81
    'dist/js/bootstrap.js']
82
} else if (BROWSERSTACK) {
83
  conf.hostname = ip.address()
84
  conf.browserStack = {
85
    username: process.env.BROWSER_STACK_USERNAME,
86
    accessKey: process.env.BROWSER_STACK_ACCESS_KEY,
87
    build: `bootstrap-v4-${new Date().toISOString()}`,
88
    project: 'Bootstrap',
89
    retryLimit: 2
90
  }
91
  plugins.push('karma-browserstack-launcher')
92
  conf.customLaunchers = browsers
93
  conf.browsers = browsersKeys
94
  reporters.push('BrowserStack')
95
  files = [...files,
96
    'node_modules/jquery/dist/jquery.slim.min.js',
97
    'js/dist/util.js',
98
    'js/dist/tooltip.js',
99
    // include all of our js/dist files except util.js, index.js and tooltip.js
100
    'js/dist/!(util|index|tooltip).js']
101
} else {
102
  frameworks.push('detectBrowsers')
103
  plugins.push(
104
    'karma-chrome-launcher',
105
    'karma-firefox-launcher',
106
    'karma-detect-browsers'
107
  )
108
  files = [...files,
109
    JQUERY_FILE,
110
    'js/coverage/dist/util.js',
111
    'js/coverage/dist/tooltip.js',
112
    // include all of our js/dist files except util.js, index.js and tooltip.js
113
    'js/coverage/dist/!(util|index|tooltip).js']
114
  conf.detectBrowsers = detectBrowsers
115
  if (!USE_OLD_JQUERY) {
116
    plugins.push('karma-coverage-istanbul-reporter')
117
    reporters.push('coverage-istanbul')
118
    conf.coverageIstanbulReporter = {
119
      dir: path.resolve(__dirname, '../coverage/'),
120
      reports: ['lcov', 'text-summary'],
121
      thresholds: {
122
        emitWarning: false,
123
        global: {
124
          statements: 90,
125
          branches: 86,
126
          functions: 89,
127
          lines: 90
128
        }
129
      }
130
    }
131
  }
132
}
133

134
files.push('js/tests/unit/*.js')
135

136
conf.frameworks = frameworks
137
conf.plugins = plugins
138
conf.reporters = reporters
139
conf.files = files
140

141
module.exports = karmaConfig => {
142
  conf.logLevel = karmaConfig.LOG_ERROR
143
  karmaConfig.set(conf)
144
}
145

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.