diff --git a/projects/shell/src/test.bootstrap.ts b/projects/shell/src/test.bootstrap.ts new file mode 100644 index 0000000..b6bc9d4 --- /dev/null +++ b/projects/shell/src/test.bootstrap.ts @@ -0,0 +1,33 @@ +// This file is required by karma.conf.js and loads recursively all the .spec and framework files + +import 'zone.js/dist/zone-testing'; +import {getTestBed} from '@angular/core/testing'; +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting +} from '@angular/platform-browser-dynamic/testing'; + +declare const require: { + context(path: string, deep?: boolean, filter?: RegExp): { + keys(): string[]; + (id: string): T; + }; +}; + +declare const __karma__: any; + +// First, initialize the Angular testing environment. +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting() +); + +// Then we find all the tests. +const c = require.context('./', true, /\.spec\.ts$/); +// And load the modules. +console.log('Context ready'); +c.keys().map(s => { + return c(s); +}); + +__karma__.start(); diff --git a/projects/shell/src/test.ts b/projects/shell/src/test.ts index 50193eb..e6957a9 100644 --- a/projects/shell/src/test.ts +++ b/projects/shell/src/test.ts @@ -1,25 +1,7 @@ -// This file is required by karma.conf.js and loads recursively all the .spec and framework files +declare const __karma__: any; -import 'zone.js/dist/zone-testing'; -import { getTestBed } from '@angular/core/testing'; -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting -} from '@angular/platform-browser-dynamic/testing'; +// Override loaded because it'll set start function as unimplemented +__karma__.loaded = () => {}; -declare const require: { - context(path: string, deep?: boolean, filter?: RegExp): { - keys(): string[]; - (id: string): T; - }; -}; - -// First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting() -); -// Then we find all the tests. -const context = require.context('./', true, /\.spec\.ts$/); -// And load the modules. -context.keys().map(context); +import('./test.bootstrap') + .catch(err => 'Failed to bootstrap tests: ' + err);