Skip to content

Commit e4c7d8a

Browse files
author
Joris Stolwijk
committed
new attempt for fixing #1906: add window.location.pathname to hrefs + comments + fixed tests
1 parent ee88ecc commit e4c7d8a

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

spec/html/HtmlReporterSpec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ describe('HtmlReporter', function() {
484484
var suiteDetail = outerSuite.childNodes[0];
485485
var suiteLink = suiteDetail.childNodes[0];
486486
expect(suiteLink.innerHTML).toEqual('A Suite');
487-
expect(suiteLink.getAttribute('href')).toEqual('?foo=bar&spec=A Suite');
487+
expect(suiteLink.getAttribute('href')).toEqual('/?foo=bar&spec=A Suite');
488488

489489
var specs = outerSuite.childNodes[1];
490490
var spec = specs.childNodes[0];
@@ -494,7 +494,7 @@ describe('HtmlReporter', function() {
494494
var specLink = spec.childNodes[0];
495495
expect(specLink.innerHTML).toEqual('with a spec');
496496
expect(specLink.getAttribute('href')).toEqual(
497-
'?foo=bar&spec=A Suite with a spec'
497+
'/?foo=bar&spec=A Suite with a spec'
498498
);
499499
});
500500

@@ -1050,7 +1050,7 @@ describe('HtmlReporter', function() {
10501050
var seedBar = container.querySelector('.jasmine-seed-bar');
10511051
expect(seedBar.textContent).toBe(', randomized with seed 424242');
10521052
var seedLink = container.querySelector('.jasmine-seed-bar a');
1053-
expect(seedLink.getAttribute('href')).toBe('?seed=424242');
1053+
expect(seedLink.getAttribute('href')).toBe('/?seed=424242');
10541054
});
10551055

10561056
it('should not show the current seed bar if not randomizing', function() {
@@ -1099,7 +1099,7 @@ describe('HtmlReporter', function() {
10991099
reporter.jasmineDone({ order: { random: true } });
11001100

11011101
var skippedLink = container.querySelector('.jasmine-skipped a');
1102-
expect(skippedLink.getAttribute('href')).toEqual('?foo=bar&spec=');
1102+
expect(skippedLink.getAttribute('href')).toEqual('/?foo=bar&spec=');
11031103
});
11041104
});
11051105

src/html/HtmlReporter.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ jasmineRequire.HtmlReporter = function(j$) {
177177
' of ' +
178178
totalSpecsDefined +
179179
' specs - run all';
180-
var skippedLink = addToExistingQueryString('spec', '');
180+
// include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
181+
var skippedLink =
182+
(window.location.pathname || '') +
183+
addToExistingQueryString('spec', '');
181184
alert.appendChild(
182185
createDom(
183186
'span',
@@ -604,7 +607,11 @@ jasmineRequire.HtmlReporter = function(j$) {
604607
suite = suite.parent;
605608
}
606609

607-
return addToExistingQueryString('spec', els.join(' '));
610+
// include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
611+
return (
612+
(window.location.pathname || '') +
613+
addToExistingQueryString('spec', els.join(' '))
614+
);
608615
}
609616

610617
function addDeprecationWarnings(result, runnableType) {
@@ -668,11 +675,19 @@ jasmineRequire.HtmlReporter = function(j$) {
668675
}
669676

670677
function specHref(result) {
671-
return addToExistingQueryString('spec', result.fullName);
678+
// include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
679+
return (
680+
(window.location.pathname || '') +
681+
addToExistingQueryString('spec', result.fullName)
682+
);
672683
}
673684

674685
function seedHref(seed) {
675-
return addToExistingQueryString('seed', seed);
686+
// include window.location.pathname to fix issue with karma-jasmine-html-reporter in angular: see https://github.com/jasmine/jasmine/issues/1906
687+
return (
688+
(window.location.pathname || '') +
689+
addToExistingQueryString('seed', seed)
690+
);
676691
}
677692

678693
function defaultQueryString(key, value) {

0 commit comments

Comments
 (0)