MOBILE-3947 tests: Fix tests configuration

main
Noel De Martin 2023-11-27 15:57:51 +01:00
parent 4286234e6b
commit b0f8f73f85
7 changed files with 508 additions and 1159 deletions

View File

@ -1,4 +1,4 @@
const { pathsToModuleNameMapper } = require('ts-jest/utils');
const { pathsToModuleNameMapper } = require('ts-jest');
const { compilerOptions } = require('./tsconfig');
module.exports = {
@ -9,17 +9,9 @@ module.exports = {
'src/**/*.{ts,html}',
'!src/testing/**/*',
],
transform: {
'^.+\\.(ts|html)$': 'ts-jest',
},
transformIgnorePatterns: ['node_modules/(?!@awesome-cordova-plugins|@ionic/core|@stencil/core|ionicons|@moodlehq/ionic-native-push)'],
transformIgnorePatterns: ['node_modules/(?!@stencil|@angular|@ionic|@moodlehq|@ngx-translate|swiper)'],
moduleNameMapper: {
...pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/src/' }),
'^!raw-loader!.*': 'jest-raw-loader',
},
globals: {
'ts-jest': {
tsconfig: './tsconfig.test.json',
},
},
};

1614
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -175,11 +175,14 @@
"gulp-rename": "^2.0.0",
"gulp-slash": "^1.1.3",
"jest": "^29.7.0",
"jest-preset-angular": "^13.1.4",
"jest-raw-loader": "^1.0.1",
"jsonc-parser": "^2.3.1",
"keytar": "^7.2.0",
"minimatch": "^5.1.0",
"native-run": "^2.0.0",
"patch-package": "^6.5.0",
"ts-jest": "^29.1.1",
"ts-node": "^8.3.0",
"typescript": "~5.1.3"
},

View File

@ -12,8 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { Route } from '@angular/compiler/src/core';
import { UrlSegment, UrlSegmentGroup } from '@angular/router';
import { Route, UrlSegment, UrlSegmentGroup } from '@angular/router';
import { mock } from '@/testing/utils';

View File

@ -1,26 +0,0 @@
// (C) Copyright 2015 Moodle Pty Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'translate',
})
export class TranslatePipeStub implements PipeTransform {
transform(text: string): string {
return text;
}
}

View File

@ -22,16 +22,15 @@ import { CORE_SITE_SCHEMAS } from '@services/sites';
import { ApplicationInit, CoreSingletonProxy, Translate } from '@singletons';
import { CoreTextUtilsProvider } from '@services/utils/text';
import { TranslatePipeStub } from './stubs/pipes/translate';
import { CoreExternalContentDirectiveStub } from './stubs/directives/core-external-content';
import { CoreNetwork } from '@services/network';
import { CorePlatform } from '@services/platform';
import { CoreDB } from '@services/db';
import { CoreNavigator, CoreNavigatorService } from '@services/navigator';
import { CoreDomUtils } from '@services/utils/dom';
import { TranslateService, TranslateStore } from '@ngx-translate/core';
import { TranslateModule, TranslateService, TranslateStore } from '@ngx-translate/core';
import { CoreIonLoadingElement } from '@classes/ion-loading';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { DefaultUrlSerializer, UrlSerializer } from '@angular/router';
import { CoreUtils, CoreUtilsProvider } from '@services/utils/utils';
import { Equal } from '@/core/utils/types';
@ -102,7 +101,8 @@ async function renderAngularComponent<T>(component: Type<T>, config: RenderConfi
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [
BrowserModule,
BrowserAnimationsModule,
NoopAnimationsModule,
TranslateModule.forChild(),
...config.imports,
],
});
@ -146,7 +146,6 @@ function createWrapperComponent<U>(template: string, componentClass: Type<U>): T
*/
function getDefaultDeclarations(): unknown[] {
return [
TranslatePipeStub,
CoreExternalContentDirectiveStub,
];
}