Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit 565320e

Browse files
committed
Merge pull request #450 from azakus/make-karma-serve-build-json
Add build.json to karma config
2 parents 2290938 + ad398c6 commit 565320e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

conf/karma.conf.js

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = function(karma) {
1313
'ShadowDOM/node_modules/chai/chai.js',
1414
'ShadowDOM/shadowdom.js',
1515
'ShadowDOM/test/test.main.js',
16+
{pattern: 'ShadowDOM/build.json', included: false},
1617
{pattern: 'ShadowDOM/src/**/*.js', included: false},
1718
{pattern: 'ShadowDOM/test/**/*.js', included: false},
1819
{pattern: 'ShadowDOM/test/**/*.html', included: false},

test/js/build-json.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,20 @@ suite('build.json', function() {
1212

1313
test('Ensure lists match', function(done) {
1414
var xhrJson = new XMLHttpRequest;
15-
xhrJson.open('GET', '../build.json');
15+
// karma serves the test runner at /context.html, need to adjust xhr request url to match
16+
var requestBase = window.__karma__ ? '/base/ShadowDOM/' : '../';
17+
xhrJson.open('GET', requestBase + 'build.json');
1618
xhrJson.onload = function() {
1719
var buildJson = JSON.parse(xhrJson.responseText);
1820

1921
var xhrJs = new XMLHttpRequest;
20-
xhrJs.open('GET', '../shadowdom.js');
22+
xhrJs.open('GET', requestBase + 'shadowdom.js');
2123
xhrJs.onload = function() {
2224
var sources = [];
2325

2426
document.write = function(s) {
2527
var path =
26-
s.slice('<script src="../'.length, - '"><\/script>'.length);
28+
s.slice(('<script src="' + requestBase).length, - '"><\/script>'.length);
2729
sources.push(path);
2830
};
2931

0 commit comments

Comments
 (0)