Skip to content

Commit

Permalink
fix: use accurate test links in HTML reporter (#5228)
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 authored Oct 29, 2024
1 parent d8ca270 commit 68803b6
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 @@ -294,7 +294,7 @@ function makeUrl(s) {
window.location.pathname +
(search ? search + '&' : '?') +
'grep=' +
encodeURIComponent(escapeRe(s))
encodeURIComponent(s)
);
}

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

/**
Expand All @@ -313,7 +313,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 68803b6

Please sign in to comment.