include all modules in coverage

This commit is contained in:
William Welling
2017-10-09 08:18:28 -05:00
parent d4602a23f7
commit 8c4c533203
10 changed files with 75 additions and 90 deletions

View File

@@ -38,25 +38,11 @@ testing.TestBed.initTestEnvironment(
browser.platformBrowserDynamicTesting()
);
/*
* Ok, this is kinda crazy. We can use the context method on
* require that webpack created in order to tell webpack
* what files we actually want to require or import.
* Below, context will be a function/object with file names as keys.
* Using that regex we are saying look in ../src then find
* any file that ends with spec.ts and get its path. By passing in true
* we say do this recursively
*/
var testContext = require.context('./src', true, /\.spec\.ts/);
/*
* get all the files, for each file, call the context function
* that will require the file and load it up here. Context will
* loop and require those spec files here
*/
function requireAll(requireContext) {
return requireContext.keys().map(requireContext);
}
var tests = require.context('./src', true, /\.spec\.ts$/);
// requires and returns all modules that match
var modules = requireAll(testContext);
tests.keys().forEach(tests);
const components = require.context('./src/app', true, /\.module\.ts$/);
components.keys().forEach(components);

View File

@@ -7,7 +7,7 @@ import { bootloader } from '@angularclass/bootloader';
import { load as loadWebFont } from 'webfontloader';
import { BrowserAppModule } from './app/browser-app.module';
import { BrowserAppModule } from './modules/app/browser-app.module';
import { ENV_CONFIG } from './config';

View File

@@ -17,7 +17,7 @@ import { enableProdMode } from '@angular/core';
import { ngExpressEngine } from '@nguniversal/express-engine';
import { ServerAppModule } from './app/server-app.module';
import { ServerAppModule } from './modules/app/server-app.module';
import { serverApi, createMockApi } from './backend/api';

View File

@@ -11,15 +11,15 @@ import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { EffectsModule } from '@ngrx/effects';
import { TransferState } from '../modules/transfer-state/transfer-state';
import { BrowserTransferStateModule } from '../modules/transfer-state/browser-transfer-state.module';
import { BrowserTransferStoreEffects } from '../modules/transfer-store/browser-transfer-store.effects';
import { BrowserTransferStoreModule } from '../modules/transfer-store/browser-transfer-store.module';
import { TransferState } from '../transfer-state/transfer-state';
import { BrowserTransferStateModule } from '../transfer-state/browser-transfer-state.module';
import { BrowserTransferStoreEffects } from '../transfer-store/browser-transfer-store.effects';
import { BrowserTransferStoreModule } from '../transfer-store/browser-transfer-store.module';
import { AppModule } from './app.module';
import { CoreModule } from './core/core.module';
import { AppModule } from '../../app/app.module';
import { CoreModule } from '../../app/core/core.module';
import { AppComponent } from './app.component';
import { AppComponent } from '../../app/app.component';
export function init(cache: TransferState) {
return () => {

View File

@@ -16,21 +16,21 @@ import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { Store } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects';
import { TranslateUniversalLoader } from '../modules/translate-universal-loader';
import { TranslateUniversalLoader } from '../translate-universal-loader';
import { ServerTransferStateModule } from '../modules/transfer-state/server-transfer-state.module';
import { TransferState } from '../modules/transfer-state/transfer-state';
import { ServerTransferStateModule } from '../transfer-state/server-transfer-state.module';
import { TransferState } from '../transfer-state/transfer-state';
import { ServerTransferStoreEffects } from '../modules/transfer-store/server-transfer-store.effects';
import { ServerTransferStoreModule } from '../modules/transfer-store/server-transfer-store.module';
import { ServerTransferStoreEffects } from '../transfer-store/server-transfer-store.effects';
import { ServerTransferStoreModule } from '../transfer-store/server-transfer-store.module';
import { AppState } from './app.reducer';
import { AppState } from '../../app/app.reducer';
import { AppModule } from './app.module';
import { AppModule } from '../../app/app.module';
import { AppComponent } from './app.component';
import { AppComponent } from '../../app/app.component';
import { GLOBAL_CONFIG, GlobalConfig } from '../config';
import { GLOBAL_CONFIG, GlobalConfig } from '../../config';
export function boot(cache: TransferState, appRef: ApplicationRef, store: Store<AppState>, request: Request, config: GlobalConfig) {
// authentication mechanism goes here

View File

@@ -1,6 +1,6 @@
{
"extends": "../tsconfig.json",
"angularCompilerOptions": {
"entryModule": "./app/browser-app.module#BrowserAppModule"
"entryModule": "./modules/app/browser-app.module#BrowserAppModule"
}
}

View File

@@ -1,6 +1,6 @@
{
"extends": "../tsconfig.json",
"angularCompilerOptions": {
"entryModule": "./app/server-app.module#ServerAppModule"
"entryModule": "./modules/app/server-app.module#ServerAppModule"
}
}

View File

@@ -4,6 +4,6 @@
"sourceMap": true
},
"angularCompilerOptions": {
"entryModule": "./app/browser-app.module#BrowserAppModule"
"entryModule": "./modules/app/browser-app.module#BrowserAppModule"
}
}

View File

@@ -225,8 +225,7 @@ module.exports = function (options) {
new ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)@angular/,
root('./src'),
{}
root('./src'), {}
),
/**