]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-21692 Introduce test failure on console errors & warnings
authorstanislavh <stanislav.honcharov@sonarsource.com>
Thu, 22 Feb 2024 13:09:03 +0000 (14:09 +0100)
committersonartech <sonartech@sonarsource.com>
Mon, 26 Feb 2024 20:02:36 +0000 (20:02 +0000)
server/sonar-web/config/jest/SetupFailOnConsole.ts [new file with mode: 0644]
server/sonar-web/design-system/jest.config.js
server/sonar-web/jest.config.js
server/sonar-web/package.json
server/sonar-web/yarn.lock

diff --git a/server/sonar-web/config/jest/SetupFailOnConsole.ts b/server/sonar-web/config/jest/SetupFailOnConsole.ts
new file mode 100644 (file)
index 0000000..36268db
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2024 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+import failOnConsole from 'jest-fail-on-console';
+const IGNORED_ERROR_MESSAGES: string[] = [];
+
+failOnConsole({
+  silenceMessage: (message) => {
+    return IGNORED_ERROR_MESSAGES.some((ignore_message) => message.includes(ignore_message));
+  },
+});
index a53f436c443da0dbcdf08c1dc91b5feea7c6cc5d..317814650ab16200ed5f248f457c227fbe97db3f 100644 (file)
@@ -48,7 +48,10 @@ module.exports = {
     '<rootDir>/config/jest/SetupTestEnvironment.js',
     '<rootDir>/config/jest/SetupTheme.js',
   ],
-  setupFilesAfterEnv: ['<rootDir>/config/jest/SetupReactTestingLibrary.ts'],
+  setupFilesAfterEnv: [
+    '<rootDir>/config/jest/SetupReactTestingLibrary.ts',
+    '<rootDir>/../config/jest/SetupFailOnConsole.ts',
+  ],
   snapshotSerializers: ['@emotion/jest/serializer'],
   testEnvironment: 'jsdom',
   testPathIgnorePatterns: [
index eb6bc2dc79c0ccde220c5132ec26f78518ae09b7..624e391868c483cffdce75f42c8225eb64dc3473 100644 (file)
@@ -35,6 +35,7 @@ module.exports = {
   setupFilesAfterEnv: [
     '<rootDir>/config/jest/SetupReactTestingLibrary.ts',
     '<rootDir>/config/jest/SetupJestAxe.ts',
+    '<rootDir>/config/jest/SetupFailOnConsole.ts',
   ],
   snapshotSerializers: ['@emotion/jest/serializer'],
   testEnvironment: 'jsdom',
index 80ae9124a4a0c72309f0f79ccdd4b9901560a745..efb6d15688808163bebd7cdbf9725860ec193dee 100644 (file)
@@ -99,6 +99,7 @@
     "jest": "29.7.0",
     "jest-axe": "8.0.0",
     "jest-environment-jsdom": "29.7.0",
+    "jest-fail-on-console": "3.1.2",
     "jest-junit": "16.0.0",
     "jest-slow-test-reporter": "1.0.0",
     "jsdom": "24.0.0",
index 9d205ad1a8af6a2234bcd6077d55f0e04dd4173e..15d46e6632bac9783dd98d373b0daaabdd089b81 100644 (file)
@@ -5486,6 +5486,7 @@ __metadata:
     jest: "npm:29.7.0"
     jest-axe: "npm:8.0.0"
     jest-environment-jsdom: "npm:29.7.0"
+    jest-fail-on-console: "npm:3.1.2"
     jest-junit: "npm:16.0.0"
     jest-slow-test-reporter: "npm:1.0.0"
     jsdom: "npm:24.0.0"
@@ -10439,6 +10440,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"jest-fail-on-console@npm:3.1.2":
+  version: 3.1.2
+  resolution: "jest-fail-on-console@npm:3.1.2"
+  checksum: 10/6f47a36cd9481121302660dbf29a6ce2443d0c2ad6ad872ee509fc538d674cdaa217f9bd041ce3771c1d8fda081ddcd85221027bbe6c9d2681cdae9d0922d329
+  languageName: node
+  linkType: hard
+
 "jest-get-type@npm:^27.4.0":
   version: 27.4.0
   resolution: "jest-get-type@npm:27.4.0"