Browse Source

SONAR-21692 Introduce test failure on console errors & warnings

tags/10.5.0.89998
stanislavh 2 months ago
parent
commit
1dba89448e

+ 27
- 0
server/sonar-web/config/jest/SetupFailOnConsole.ts View File

@@ -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));
},
});

+ 4
- 1
server/sonar-web/design-system/jest.config.js View 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: [

+ 1
- 0
server/sonar-web/jest.config.js View 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',

+ 1
- 0
server/sonar-web/package.json View 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",

+ 8
- 0
server/sonar-web/yarn.lock View 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"

Loading…
Cancel
Save