Skip to content

Commit b203a3c

Browse files
committed
always include lib/index.js in single-suite jasmine runs,
- so that individual suite run without import conflicts
1 parent a075f81 commit b203a3c

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

test/jasmine/karma.conf.js

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@
1212
* will only run the tests in axes_test.js
1313
*
1414
*/
15-
var testFileGlob = process.argv[4] ? process.argv[4] : 'tests/*_test.js';
15+
16+
var arg = process.argv[4];
17+
18+
var testFileGlob = arg ? arg : 'tests/*_test.js';
19+
var isSingleSuiteRun = (arg && arg.indexOf('bundle_tests/') === -1);
20+
21+
var pathToMain = '../../lib/index.js';
22+
var pathToJQuery = 'assets/jquery-1.8.3.min.js';
1623

1724

1825
function func(config) {
@@ -34,10 +41,9 @@ func.defaultConfig = {
3441
frameworks: ['jasmine', 'browserify'],
3542

3643
// list of files / patterns to load in the browser
37-
files: [
38-
'assets/jquery-1.8.3.min.js',
39-
testFileGlob
40-
],
44+
//
45+
// N.B. this field is filled below
46+
files: [],
4147

4248
exclude: [],
4349

@@ -77,7 +83,27 @@ func.defaultConfig = {
7783
}
7884
};
7985

80-
// browserify the test files
81-
func.defaultConfig.preprocessors[testFileGlob] = ['browserify'];
86+
87+
// Add lib/index.js to single-suite runs,
88+
// to avoid import conflicts due to plotly.js
89+
// circular dependencies.
90+
if(isSingleSuiteRun) {
91+
func.defaultConfig.files = [
92+
pathToJQuery,
93+
pathToMain,
94+
testFileGlob
95+
];
96+
97+
func.defaultConfig.preprocessors[pathToMain] = ['browserify'];
98+
func.defaultConfig.preprocessors[testFileGlob] = ['browserify'];
99+
}
100+
else {
101+
func.defaultConfig.files = [
102+
pathToJQuery,
103+
testFileGlob
104+
];
105+
106+
func.defaultConfig.preprocessors[testFileGlob] = ['browserify'];
107+
}
82108

83109
module.exports = func;

0 commit comments

Comments
 (0)