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

Commit

Permalink
Add build.json to karma config
Browse files Browse the repository at this point in the history
Karma serves the testrunner as /context.html, so we adjust XHR paths when we detect running under karma
  • Loading branch information
dfreedm committed May 30, 2014
1 parent 2290938 commit ad398c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions conf/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = function(karma) {
'ShadowDOM/node_modules/chai/chai.js',
'ShadowDOM/shadowdom.js',
'ShadowDOM/test/test.main.js',
{pattern: 'ShadowDOM/build.json', included: false},
{pattern: 'ShadowDOM/src/**/*.js', included: false},
{pattern: 'ShadowDOM/test/**/*.js', included: false},
{pattern: 'ShadowDOM/test/**/*.html', included: false},
Expand Down
8 changes: 5 additions & 3 deletions test/js/build-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ suite('build.json', function() {

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

var xhrJs = new XMLHttpRequest;
xhrJs.open('GET', '../shadowdom.js');
xhrJs.open('GET', requestBase + 'shadowdom.js');
xhrJs.onload = function() {
var sources = [];

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

Expand Down

0 comments on commit ad398c6

Please sign in to comment.