Skip to content

Commit

Permalink
mgr/dashboard: adapt and refactor jest test files
Browse files Browse the repository at this point in the history
Use the `configureTestBed` as the placeholder for adding the
declarations, imports... that is required for the unit tests to run

Fixes: https://tracker.ceph.com/issues/62844
Signed-off-by: Nizamudeen A <nia@redhat.com>
  • Loading branch information
nizamial09 committed Sep 26, 2023
1 parent 47f49e5 commit e2626fb
Show file tree
Hide file tree
Showing 37 changed files with 16,159 additions and 13,513 deletions.
77 changes: 36 additions & 41 deletions src/pybind/mgr/dashboard/frontend/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,44 +1,39 @@
const esModules = ['@angular', '@ngrx', '@progress', 'simplebar', 'lodash-es', 'react-syntax-highlighter', 'swagger-client', '@ng-bootstrap'];
const esModules = [
'@angular',
'@ngrx',
'@progress',
'simplebar',
'lodash-es',
'react-syntax-highlighter',
'swagger-client',
'@ng-bootstrap'
];
const jestConfig = {
globals: {
'ts-jest': {
useESM: true,
stringifyContentPathRegex: '\\.(html|svg)$',
tsconfig: '<rootDir>/tsconfig.spec.json',
isolatedModules: true
},
},
globalSetup: 'jest-preset-angular/global-setup',
moduleNameMapper: {
"\\.scss$": "identity-obj-proxy",
"~/(.*)$": "<rootDir>/src/$1"
},
moduleFileExtensions: ['ts', 'html', 'js', 'json', 'mjs', 'cjs'],
preset: "jest-preset-angular",
setupFilesAfterEnv: [
"<rootDir>/src/setupJest.ts"
],
transformIgnorePatterns: [
"node_modules/(?!.*\\.mjs$|".concat(esModules.join('|'), ")")
],
transform: {
"^.+\\.(ts|html|mjs)$": "jest-preset-angular",
"^.+\\.(js)$": "babel-jest"
},
setupFiles: [
"jest-canvas-mock"
],
coverageReporters: [
"cobertura",
"html"
],
modulePathIgnorePatterns: [
"<rootDir>/coverage/",
"<rootDir>/node_modules/simplebar-angular",
],
testMatch: [
"**/*.spec.ts"
],
testRunner: 'jest-jasmine2'
globals: {
'ts-jest': {
useESM: true,
stringifyContentPathRegex: '\\.(html|svg)$',
tsconfig: '<rootDir>/tsconfig.spec.json',
isolatedModules: true
}
},
globalSetup: 'jest-preset-angular/global-setup',
moduleNameMapper: {
'\\.scss$': 'identity-obj-proxy',
'~/(.*)$': '<rootDir>/src/$1'
},
moduleFileExtensions: ['ts', 'html', 'js', 'json', 'mjs', 'cjs'],
preset: 'jest-preset-angular',
setupFilesAfterEnv: ['<rootDir>/src/setupJest.ts'],
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$|'.concat(esModules.join('|'), ')')],
transform: {
'^.+\\.(ts|html|mjs)$': 'jest-preset-angular',
'^.+\\.(js)$': 'babel-jest'
},
setupFiles: ['jest-canvas-mock'],
coverageReporters: ['cobertura', 'html'],
modulePathIgnorePatterns: ['<rootDir>/coverage/', '<rootDir>/node_modules/simplebar-angular'],
testMatch: ['**/*.spec.ts'],
testRunner: 'jest-jasmine2'
};
module.exports = jestConfig;
Loading

0 comments on commit e2626fb

Please sign in to comment.