Skip to content

Commit 6d7782a

Browse files
committed
fix: use accurate test links in HTML reporter
- 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 1173da0 commit 6d7782a

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
@@ -269,7 +269,7 @@ function makeUrl(s) {
269269
window.location.pathname +
270270
(search ? search + '&' : '?') +
271271
'grep=' +
272-
encodeURIComponent(escapeRe(s))
272+
encodeURIComponent(s)
273273
);
274274
}
275275

@@ -279,7 +279,7 @@ function makeUrl(s) {
279279
* @param {Object} [suite]
280280
*/
281281
HTML.prototype.suiteURL = function (suite) {
282-
return makeUrl(suite.fullTitle());
282+
return makeUrl('^' + escapeRe(suite.fullTitle()) + ' ');
283283
};
284284

285285
/**
@@ -288,7 +288,7 @@ HTML.prototype.suiteURL = function (suite) {
288288
* @param {Object} [test]
289289
*/
290290
HTML.prototype.testURL = function (test) {
291-
return makeUrl(test.fullTitle());
291+
return makeUrl('^' + escapeRe(test.fullTitle()) + '$');
292292
};
293293

294294
/**

0 commit comments

Comments
 (0)