Skip to content

Commit

Permalink
fix: use accurate test links in HTML reporter
Browse files Browse the repository at this point in the history
- Add '^' and ' ' for a suite link so that a link for `Case1` won't hit `Case10 test1`.
- Add '^' and '$' for a test link so that a link for `CSS` won't hit `should fix invalid CSS`.
  • Loading branch information
danny0838 committed Oct 12, 2024
1 parent 1173da0 commit 6d7782a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/reporters/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function makeUrl(s) {
window.location.pathname +
(search ? search + '&' : '?') +
'grep=' +
encodeURIComponent(escapeRe(s))
encodeURIComponent(s)
);
}

Expand All @@ -279,7 +279,7 @@ function makeUrl(s) {
* @param {Object} [suite]
*/
HTML.prototype.suiteURL = function (suite) {
return makeUrl(suite.fullTitle());
return makeUrl('^' + escapeRe(suite.fullTitle()) + ' ');
};

/**
Expand All @@ -288,7 +288,7 @@ HTML.prototype.suiteURL = function (suite) {
* @param {Object} [test]
*/
HTML.prototype.testURL = function (test) {
return makeUrl(test.fullTitle());
return makeUrl('^' + escapeRe(test.fullTitle()) + '$');
};

/**
Expand Down

0 comments on commit 6d7782a

Please sign in to comment.