From fc3d26b18cc1ef0e62f3ecfb868fe6d53e0cfde5 Mon Sep 17 00:00:00 2001 From: Andreas Pfurtscheller <1051396+aplr@users.noreply.github.com> Date: Sat, 14 Oct 2023 14:00:26 +0200 Subject: [PATCH] Remove deprecated ts-jest globals configuration in jest.config.js, disable eslint in jest config --- jest.config.js | 100 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 76 insertions(+), 24 deletions(-) diff --git a/jest.config.js b/jest.config.js index 26ab84c96cca..8a763f782fe6 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,10 +1,53 @@ -const esModules = ['lodash-es', 'franc-min', 'trigram-utils', 'n-gram', 'collapse-white-space', '@angular/animations', '@angular/common', '@ls1intum/apollon', - '@angular/compiler', '@angular/core', '@angular/forms', '@angular/localize', '@angular/platform-browser', '@angular/platform-browser-dynamic', '@angular/router', - '@ngx-translate/core', '@ngx-translate/http-loader', '@fortawesome/angular-fontawesome', '@angular/cdk', '@angular/material', '@angular/cdk', 'dayjs/esm', - 'rxjs/operators', '@ng-bootstrap/ng-bootstrap', 'ngx-webstorage', '@ctrl/ngx-emoji-mart', 'ngx-device-detector', '@swimlane/ngx-charts', - '@angular/service-worker', '@danielmoncada/angular-datetime-picker', '@flaviosantoro92/ngx-datatable', 'd3-color', 'd3-interpolate', 'd3-transition', 'd3-brush', - 'd3-drag', 'd3-selection', 'd3-scale', 'd3-array', 'd3-format', 'd3-shape', 'd3-path', 'd3-ease', 'd3-time', 'd3-hierarchy', 'ngx-infinite-scroll', 'internmap', - '@swimlane/ngx-graph'].join('|'); +const esModules = [ + 'lodash-es', + 'franc-min', + 'trigram-utils', + 'n-gram', + 'collapse-white-space', + '@angular/animations', + '@angular/common', + '@ls1intum/apollon', + '@angular/compiler', + '@angular/core', + '@angular/forms', + '@angular/localize', + '@angular/platform-browser', + '@angular/platform-browser-dynamic', + '@angular/router', + '@ngx-translate/core', + '@ngx-translate/http-loader', + '@fortawesome/angular-fontawesome', + '@angular/cdk', + '@angular/material', + '@angular/cdk', + 'dayjs/esm', + 'rxjs/operators', + '@ng-bootstrap/ng-bootstrap', + 'ngx-webstorage', + '@ctrl/ngx-emoji-mart', + 'ngx-device-detector', + '@swimlane/ngx-charts', + '@angular/service-worker', + '@danielmoncada/angular-datetime-picker', + '@flaviosantoro92/ngx-datatable', + 'd3-color', + 'd3-interpolate', + 'd3-transition', + 'd3-brush', + 'd3-drag', + 'd3-selection', + 'd3-scale', + 'd3-array', + 'd3-format', + 'd3-shape', + 'd3-path', + 'd3-ease', + 'd3-time', + 'd3-hierarchy', + 'ngx-infinite-scroll', + 'internmap', + '@swimlane/ngx-graph', +].join('|'); const { compilerOptions: { baseUrl = './' }, @@ -12,25 +55,24 @@ const { module.exports = { globalSetup: 'jest-preset-angular/global-setup', - globals: { - 'ts-jest': { - tsconfig: '/tsconfig.spec.json', - stringifyContentPathRegex: '\\.html$', - isolatedModules: true, - diagnostics: { - ignoreCodes: [151001], - }, - }, - }, testEnvironmentOptions: { - url: 'https://artemis.fake/test' + url: 'https://artemis.fake/test', }, roots: ['', `/${baseUrl}`], modulePaths: [`/${baseUrl}`], setupFiles: ['jest-date-mock'], cacheDirectory: '/build/jest-cache', coverageDirectory: '/build/test-results/', - reporters: ['default', ['jest-junit', { outputDirectory: '/build/test-results/', outputName: 'TESTS-results-jest.xml' }]], + reporters: [ + 'default', + [ + 'jest-junit', + { + outputDirectory: '/build/test-results/', + outputName: 'TESTS-results-jest.xml', + }, + ], + ], collectCoverageFrom: ['src/main/webapp/**/*.{js,jsx,ts,tsx}', '!src/main/webapp/**/*.module.{js,jsx,ts,tsx}'], coveragePathIgnorePatterns: [ '/node_modules/', @@ -53,7 +95,7 @@ module.exports = { 'src/main/webapp/app/exercises/modeling/manage/modeling-exercise.route.ts', 'src/main/webapp/app/exam/manage/exam-management.route.ts', 'src/main/webapp/app/exercises/shared/exercise-hint/manage/exercise-hint.route.ts', - 'src/main/webapp/app/core/config/prod.config.ts' + 'src/main/webapp/app/core/config/prod.config.ts', ], coverageThreshold: { global: { @@ -64,13 +106,23 @@ module.exports = { lines: 85.8, }, }, - coverageReporters: ["clover", "json", "lcov", "text-summary"], + coverageReporters: ['clover', 'json', 'lcov', 'text-summary'], setupFilesAfterEnv: ['/src/test/javascript/spec/jest-test-setup.ts', 'jest-extended/all'], moduleFileExtensions: ['ts', 'html', 'js', 'json', 'mjs'], resolver: '/jest.resolver.js', transformIgnorePatterns: [`/node_modules/(?!${esModules})`], transform: { - '^.+\\.(ts|js|mjs|html|svg)$': 'jest-preset-angular', + '^.+\\.(ts|js|mjs|html|svg)$': [ + 'jest-preset-angular', + { + tsconfig: '/tsconfig.spec.json', + stringifyContentPathRegex: '\\.html$', + isolatedModules: true, + diagnostics: { + ignoreCodes: [151001], + }, + }, + ], }, modulePathIgnorePatterns: [], testTimeout: 3000, @@ -84,7 +136,7 @@ module.exports = { '/src/test/javascript/spec/util/**/*.spec.ts', '/src/test/javascript/spec/interceptor/**/*.spec.ts', '/src/test/javascript/spec/config/**/*.spec.ts', - '/src/test/javascript/spec/core/**/*.spec.ts' + '/src/test/javascript/spec/core/**/*.spec.ts', ], moduleNameMapper: { '^app/(.*)': '/src/main/webapp/app/$1', @@ -94,6 +146,6 @@ module.exports = { '@env': '/src/main/webapp/environments/environment', '@src/(.*)': '/src/src/$1', '@state/(.*)': '/src/app/state/$1', - "^lodash-es$": "lodash" + '^lodash-es$': 'lodash', }, };