Skip to content

Commit 68803b6

Browse files
authored
fix: use accurate test links in HTML reporter (#5228)
- 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`.
1 parent d8ca270 commit 68803b6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/reporters/html.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ function makeUrl(s) {
294294
window.location.pathname +
295295
(search ? search + '&' : '?') +
296296
'grep=' +
297-
encodeURIComponent(escapeRe(s))
297+
encodeURIComponent(s)
298298
);
299299
}
300300

@@ -304,7 +304,7 @@ function makeUrl(s) {
304304
* @param {Object} [suite]
305305
*/
306306
HTML.prototype.suiteURL = function (suite) {
307-
return makeUrl(suite.fullTitle());
307+
return makeUrl('^' + escapeRe(suite.fullTitle()) + ' ');
308308
};
309309

310310
/**
@@ -313,7 +313,7 @@ HTML.prototype.suiteURL = function (suite) {
313313
* @param {Object} [test]
314314
*/
315315
HTML.prototype.testURL = function (test) {
316-
return makeUrl(test.fullTitle());
316+
return makeUrl('^' + escapeRe(test.fullTitle()) + '$');
317317
};
318318

319319
/**

0 commit comments

Comments
 (0)