Skip to content

Commit a3a6bea

Browse files
author
Chris Decoster
committed
wip karma config for webstorm support. More work is needed to get files and the baseUrl to work in all three scenarios.
1 parent a8a22ee commit a3a6bea

File tree

1 file changed

+19
-43
lines changed

1 file changed

+19
-43
lines changed

lib/test/karma.js

Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,8 @@ var gulp = require('gulp'),
99
childProcess = require('child_process');
1010

1111
var yargs = require('../util/yargs'),
12-
streams = require('../config/streams'),
1312
platform = require('../config/platform');
1413

15-
/**
16-
* Wrap the given value in quotation marks
17-
* @param {*} value The value to wrap
18-
* @returns {string} The string representation of the value in quotation marks
19-
*/
20-
function quote(value) {
21-
return '"' + value + '"';
22-
}
23-
2414
var defaultReporterName = 'karma-angularity-reporter';
2515

2616
var filesAppendRegex = /\/\*+\s*ANGULARITY_FILE_LIST\s*\*+\// ;
@@ -95,7 +85,7 @@ function getKarmaReporterName(reporterName) {
9585
if (!!match && match.length === 2) {
9686
name = match[1];
9787
}
98-
return name
88+
return name;
9989
}
10090

10191
/**
@@ -118,25 +108,33 @@ function karmaCreateConfig(reporters, configFileName) {
118108
configFileName = configFileName || 'karma.conf.js';
119109
var files = [];
120110

111+
files.push('**/!(app|app-build|app-release|app-test)/*.js');
112+
113+
files.push({
114+
'pattern': '**/*.map',
115+
'included': false
116+
});
117+
118+
files.push({
119+
'pattern': '**/*.spec.js',
120+
'included': false
121+
});
122+
123+
// add the bundles
121124
function transformFn(file, encoding, transformDone) {
122125
if (!file || !file.path) {
123126
throw 'Files must have paths';
124127
}
125128
if (path.extname(file.path) === '.js') {
126129
files.push(file.path);
127130
}
128-
else {
129-
//non-javascript files, such as source maps, should be included but not tested
130-
files.push({
131-
pattern: file.path,
132-
included: false,
133-
});
134-
}
135131
transformDone();
136132
}
137133

138134
function flushFn(flushDone) {
135+
/*jshint validthis:true */
139136
var stream = this;
137+
constructFile();
140138

141139
function constructFile() {
142140
var filesAppend = JSON.stringify(files, null, ' ');
@@ -160,28 +158,7 @@ function karmaCreateConfig(reporters, configFileName) {
160158
.on('end', function() {
161159
flushDone();
162160
});
163-
}
164-
165-
function specTransformFn(file, encoding, specFileDone) {
166-
files.push({
167-
pattern: file.path,
168-
included: false,
169-
});
170-
specFileDone();
171-
}
172-
173-
function specFlushFn(specFlushDone) {
174-
//delay construction of file until all *.spec.js files have been
175-
//added to the files array
176-
constructFile();
177-
specFlushDone();
178161
}
179-
180-
//obtain a list of *.spec.js files (file contents skipped)
181-
//and add them to the list of files, with `included: false`,
182-
//prior to writing to file
183-
streams.jsSpec({ read: false })
184-
.pipe(through.obj(specTransformFn, specFlushFn));
185162
}
186163

187164
return through.obj(transformFn, flushFn);
@@ -193,10 +170,9 @@ function karmaCreateConfig(reporters, configFileName) {
193170
* Runs karma in a child process, to avoid `process.exit()` called by karma.
194171
*
195172
* @param {Array.<string>} [reporters] The name of the karma reporter to use
196-
* @param {number} [bannerWidth] The width of banner comment, zero or omitted for none
197173
* @returns {stream.Through} A through stream intended to have a gulp stream piped through it
198174
*/
199-
function karmaRun(reporters, bannerWidth) {
175+
function karmaRun(reporters) {
200176
var options = {
201177
configFile: undefined
202178
};
@@ -222,12 +198,12 @@ function karmaRun(reporters, bannerWidth) {
222198
SUPPORTS_COLOR: true,
223199
}),
224200
});
225-
karmaBackground.on('close', function(exitCode) {
201+
karmaBackground.on('close', function() {
226202
done();
227203
return;
228204
});
229205
});
230-
};
206+
}
231207

232208
var yargsOptionDefiniton = {
233209
key: 'karmareporter',

0 commit comments

Comments
 (0)