From 7078d11f2c98a2ba27f63a19ea2de9e86ab01523 Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Sat, 12 Oct 2024 08:42:45 +0800 Subject: [PATCH] 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`. --- 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 ae4a4546f8..ec06760a01 100644 --- a/lib/reporters/html.js +++ b/lib/reporters/html.js @@ -269,7 +269,7 @@ function makeUrl(s) { window.location.pathname + (search ? search + '&' : '?') + 'grep=' + - encodeURIComponent(escapeRe(s)) + encodeURIComponent(s) ); } @@ -279,7 +279,7 @@ function makeUrl(s) { * @param {Object} [suite] */ HTML.prototype.suiteURL = function (suite) { - return makeUrl(suite.fullTitle()); + return makeUrl('^' + escapeRe(suite.fullTitle()) + ' '); }; /** @@ -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()) + '$'); }; /**