forked from elementor/elementor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
karma.conf.js
144 lines (124 loc) · 3.93 KB
/
karma.conf.js
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
let isDebug = false;
if ( process.argv[ process.argv.length - 1 ] ) {
const gruntParams = process.argv[ process.argv.length - 1 ].split( ':' );
if ( gruntParams ) {
if ( 'karma' === gruntParams[ 0 ] ) {
if ( 'debug' === gruntParams[ 1 ] ) {
isDebug = true;
}
}
}
}
// Read package.json
const packageJson = require( './package.json' );
module.exports = function( config ) {
const karmaConfig = {
basePath: './',
frameworks: [ 'qunit' ],
files: [
{
pattern: 'assets/js/**/*.js.map',
included: false,
},
// Base Libraries.
'tests/qunit/vendor/wp-includes/jquery.js',
'tests/qunit/vendor/wp-includes/underscore.min.js',
'tests/qunit/vendor/wp-includes/backbone.min.js',
'tests/qunit/vendor/wp-includes/react.min.js',
'tests/qunit/vendor/wp-includes/react-dom.min.js',
'tests/qunit/vendor/wp-includes/i18n.min.js',
'assets/lib/backbone/backbone.marionette.min.js',
'assets/lib/backbone/backbone.radio.min.js',
// Dev tools.
'tests/qunit/setup/dev-tools.js',
'assets/js/dev-tools.js',
// Elementor Common.
'tests/qunit/setup/elementor-common.js',
'tests/qunit/setup/web-cli.js',
'assets/lib/dialog/dialog.js',
'assets/js/common-modules.min.js',
'assets/js/web-cli.min.js',
'assets/js/common.min.js',
// Editor Fixtures.
'tests/qunit/index.html',
// Editor Tinymce.
'tests/qunit/setup/tinymce.js',
'tests/qunit/vendor/wp-includes/quicktags.min.js',
// Editor Config.
'tests/qunit/setup/editor.js',
// Editor Dependencies.
'tests/qunit/vendor/wp-includes/jquery-ui.min.js',
'assets/lib/tipsy/tipsy.min.js',
'assets/lib/perfect-scrollbar/js/perfect-scrollbar.min.js',
'assets/lib/nouislider/nouislider.min.js',
'assets/lib/imagesloaded/imagesloaded.min.js',
'assets/dev/js/editor/utils/jquery-serialize-object.js',
'assets/dev/js/editor/utils/jquery-html5-dnd.js',
'assets/lib/jquery-hover-intent/jquery-hover-intent.min.js',
// Editor.
'assets/js/editor-modules.min.js',
'assets/js/editor-document.min.js',
// Tests.
'assets/js/qunit-tests.min.js',
],
preprocessors: {
'tests/qunit/index.html': [ 'html2js' ],
'assets/js/common-modules.js': [ 'coverage' ],
'assets/js/common.js': [ 'coverage' ],
'assets/js/editor-document.js': [ 'coverage' ],
},
reporters: [ 'progress' ],
coverageIstanbulReporter: {
reports: [ 'text' ],
fixWebpackSourcePaths: true,
// Enforce percentage thresholds
// anything under these percentages will cause karma to fail with an exit code of 1 if not running in watch mode
thresholds: {
emitWarning: false, // Set to `true` to not fail the test command when thresholds are not met
// thresholds for all files
global: {
statements: 50, /* TEMP: initial value */
lines: 55, /* TEMP: initial value */
branches: 25, /* TEMP: initial value */
functions: 55, /* TEMP: initial value */
},
},
},
// Web server port
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
browsers: [ 'ChromeHeadlessCustom', 'ChromeHeadless' ],
customLaunchers: {
ChromeHeadlessCustom: {
base: 'ChromeHeadless',
flags: [ '--no-sandbox', '--single-process' ],
},
},
browserDisconnectTimeout: 6000,
pingTimeout: 10000,
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
// Client configuration
client: {
clearContext: true,
qunit: {
elementorVersion: packageJson.version,
isDebug,
showUI: false,
validateContainersAlive: true, // Validate all containers are alive recursively after each test done.
testTimeout: 5000,
},
},
};
if ( isDebug ) {
const fs = require( 'fs' );
if ( fs.existsSync( '../elementor-dev-tools' ) ) {
const last = karmaConfig.files.pop();
karmaConfig.files.push( { pattern: '../elementor-dev-tools/assets/js/editor.js', type: 'module' } );
karmaConfig.files.push( last );
}
}
config.set( karmaConfig );
};