From 68803b685d55dcccc51fa6ccfd27701cda4e26ed Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Wed, 30 Oct 2024 04:19:52 +0800 Subject: [PATCH] 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`. --- lib/reporters/html.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/reporters/html.js b/lib/reporters/html.js index c970fc05e9..7f4fa673fc 100644 --- a/lib/reporters/html.js +++ b/lib/reporters/html.js @@ -294,7 +294,7 @@ function makeUrl(s) { window.location.pathname + (search ? search + '&' : '?') + 'grep=' + - encodeURIComponent(escapeRe(s)) + encodeURIComponent(s) ); } @@ -304,7 +304,7 @@ function makeUrl(s) { * @param {Object} [suite] */ HTML.prototype.suiteURL = function (suite) { - return makeUrl(suite.fullTitle()); + return makeUrl('^' + escapeRe(suite.fullTitle()) + ' '); }; /** @@ -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()) + '$'); }; /**