101108: Angular 15 upgrade - test build & run fixes

This commit is contained in:
Kristof De Langhe
2023-04-12 17:47:40 +02:00
parent 84f1fcbb35
commit 4ed6ccebff
3 changed files with 5 additions and 12 deletions

View File

@@ -17,9 +17,9 @@
"build:stats": "ng build --stats-json", "build:stats": "ng build --stats-json",
"build:prod": "yarn run build:ssr", "build:prod": "yarn run build:ssr",
"build:ssr": "ng build --configuration production && ng run dspace-angular:server:production", "build:ssr": "ng build --configuration production && ng run dspace-angular:server:production",
"test": "ng test --sourceMap=true --watch=false --configuration test", "test": "ng test --source-map=true --watch=false --configuration test",
"test:watch": "nodemon --exec \"ng test --sourceMap=true --watch=true --configuration test\"", "test:watch": "nodemon --exec \"ng test --source-map=true --watch=true --configuration test\"",
"test:headless": "ng test --sourceMap=true --watch=false --configuration test --browsers=ChromeHeadless --code-coverage", "test:headless": "ng test --source-map=true --watch=false --configuration test --browsers=ChromeHeadless --code-coverage",
"lint": "ng lint", "lint": "ng lint",
"lint-fix": "ng lint --fix=true", "lint-fix": "ng lint --fix=true",
"e2e": "ng e2e", "e2e": "ng e2e",
@@ -203,4 +203,4 @@
"webpack-cli": "^4.2.0", "webpack-cli": "^4.2.0",
"webpack-dev-server": "^4.5.0" "webpack-dev-server": "^4.5.0"
} }
} }

View File

@@ -72,7 +72,7 @@ export function createPaginatedList<T>(objects?: T[]): PaginatedList<T> {
* @param prop The property/function to spy on * @param prop The property/function to spy on
*/ */
export function spyOnExported<T>(target: T, prop: keyof T): jasmine.Spy { export function spyOnExported<T>(target: T, prop: keyof T): jasmine.Spy {
const spy = jasmine.createSpy(`${prop}Spy`); const spy = jasmine.createSpy(`${String(prop)}Spy`);
spyOnProperty(target, prop).and.returnValue(spy); spyOnProperty(target, prop).and.returnValue(spy);
return spy; return spy;
} }

View File

@@ -9,8 +9,6 @@ import {
} from '@angular/platform-browser-dynamic/testing'; } from '@angular/platform-browser-dynamic/testing';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
declare const require: any;
// First, initialize the Angular testing environment. // First, initialize the Angular testing environment.
getTestBed().initTestEnvironment( getTestBed().initTestEnvironment(
BrowserDynamicTestingModule, BrowserDynamicTestingModule,
@@ -24,8 +22,3 @@ jasmine.getEnv().afterEach(() => {
// Close any leftover modals // Close any leftover modals
getTestBed().inject(NgbModal, null)?.dismissAll?.(); getTestBed().inject(NgbModal, null)?.dismissAll?.();
}); });
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);