diff --git a/core/tests/Drupal/Nightwatch/Assertions/deprecationErrorExists.js b/core/tests/Drupal/Nightwatch/Assertions/deprecationErrorExists.js
index b3ea3c24fe82e289c6d46810839e7edee04073bd..2bc60eb1985aac4ab2b1238930c2c161f3a3a8c3 100644
--- a/core/tests/Drupal/Nightwatch/Assertions/deprecationErrorExists.js
+++ b/core/tests/Drupal/Nightwatch/Assertions/deprecationErrorExists.js
@@ -7,7 +7,7 @@ module.exports.assertion = function (expected) {
     const deprecationMessages =
       sessionStorageEntries !== null
         ? sessionStorageEntries.filter((message) =>
-            new RegExp('[Deprecation]').test(message),
+            message.includes('[Deprecation]'),
           )
         : [];
 
diff --git a/core/tests/Drupal/Nightwatch/Assertions/noDeprecationErrors.js b/core/tests/Drupal/Nightwatch/Assertions/noDeprecationErrors.js
index 860b5de9fccbd0457bb7c8952905281083d1c4b7..e4715598a59954896ac4498a1a90bc2053e08dcf 100644
--- a/core/tests/Drupal/Nightwatch/Assertions/noDeprecationErrors.js
+++ b/core/tests/Drupal/Nightwatch/Assertions/noDeprecationErrors.js
@@ -7,7 +7,7 @@ module.exports.assertion = function () {
     const deprecationMessages =
       sessionStorageEntries !== null
         ? sessionStorageEntries.filter((message) =>
-            new RegExp('[Deprecation]').test(message),
+            message.includes('[Deprecation]'),
           )
         : [];