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() 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/);
/* var tests = 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);
}
// requires and returns all modules that match tests.keys().forEach(tests);
var modules = requireAll(testContext);
const components = require.context('./src/app', true, /\.module\.ts$/);
components.keys().forEach(components);

View File

@@ -1,17 +1,17 @@
import { ActionReducerMap } from '@ngrx/store'; import { ActionReducerMap } from '@ngrx/store';
import * as fromRouter from '@ngrx/router-store'; import * as fromRouter from '@ngrx/router-store';
import { headerReducer, HeaderState } from './header/header.reducer'; import { headerReducer, HeaderState } from './header/header.reducer';
import { hostWindowReducer, HostWindowState } from './shared/host-window.reducer'; import { hostWindowReducer, HostWindowState } from './shared/host-window.reducer';
export interface AppState { export interface AppState {
router: fromRouter.RouterReducerState; router: fromRouter.RouterReducerState;
hostWindow: HostWindowState; hostWindow: HostWindowState;
header: HeaderState; header: HeaderState;
} }
export const appReducers: ActionReducerMap<AppState> = { export const appReducers: ActionReducerMap<AppState> = {
router: fromRouter.routerReducer, router: fromRouter.routerReducer,
hostWindow: hostWindowReducer, hostWindow: hostWindowReducer,
header: headerReducer header: headerReducer
}; };

View File

@@ -1,31 +1,31 @@
import 'zone.js/dist/zone'; import 'zone.js/dist/zone';
import 'reflect-metadata'; import 'reflect-metadata';
import { enableProdMode } from '@angular/core'; import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { bootloader } from '@angularclass/bootloader'; import { bootloader } from '@angularclass/bootloader';
import { load as loadWebFont } from 'webfontloader'; 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'; import { ENV_CONFIG } from './config';
if (ENV_CONFIG.production) { if (ENV_CONFIG.production) {
enableProdMode(); enableProdMode();
} }
export function main() { export function main() {
// Load fonts async // Load fonts async
// https://github.com/typekit/webfontloader#configuration // https://github.com/typekit/webfontloader#configuration
loadWebFont({ loadWebFont({
google: { google: {
families: ['Droid Sans'] families: ['Droid Sans']
} }
}); });
return platformBrowserDynamic().bootstrapModule(BrowserAppModule); return platformBrowserDynamic().bootstrapModule(BrowserAppModule);
} }
// support async tag or hmr // support async tag or hmr
bootloader(main); bootloader(main);

View File

@@ -17,7 +17,7 @@ import { enableProdMode } from '@angular/core';
import { ngExpressEngine } from '@nguniversal/express-engine'; 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'; 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 { EffectsModule } from '@ngrx/effects';
import { TransferState } from '../modules/transfer-state/transfer-state'; import { TransferState } from '../transfer-state/transfer-state';
import { BrowserTransferStateModule } from '../modules/transfer-state/browser-transfer-state.module'; import { BrowserTransferStateModule } from '../transfer-state/browser-transfer-state.module';
import { BrowserTransferStoreEffects } from '../modules/transfer-store/browser-transfer-store.effects'; import { BrowserTransferStoreEffects } from '../transfer-store/browser-transfer-store.effects';
import { BrowserTransferStoreModule } from '../modules/transfer-store/browser-transfer-store.module'; import { BrowserTransferStoreModule } from '../transfer-store/browser-transfer-store.module';
import { AppModule } from './app.module'; import { AppModule } from '../../app/app.module';
import { CoreModule } from './core/core.module'; import { CoreModule } from '../../app/core/core.module';
import { AppComponent } from './app.component'; import { AppComponent } from '../../app/app.component';
export function init(cache: TransferState) { export function init(cache: TransferState) {
return () => { return () => {

View File

@@ -16,21 +16,21 @@ import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects'; 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 { ServerTransferStateModule } from '../transfer-state/server-transfer-state.module';
import { TransferState } from '../modules/transfer-state/transfer-state'; import { TransferState } from '../transfer-state/transfer-state';
import { ServerTransferStoreEffects } from '../modules/transfer-store/server-transfer-store.effects'; import { ServerTransferStoreEffects } from '../transfer-store/server-transfer-store.effects';
import { ServerTransferStoreModule } from '../modules/transfer-store/server-transfer-store.module'; 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) { export function boot(cache: TransferState, appRef: ApplicationRef, store: Store<AppState>, request: Request, config: GlobalConfig) {
// authentication mechanism goes here // authentication mechanism goes here

View File

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

View File

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

View File

@@ -4,6 +4,6 @@
"sourceMap": true "sourceMap": true
}, },
"angularCompilerOptions": { "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( new ContextReplacementPlugin(
/angular(\\|\/)core(\\|\/)@angular/, /angular(\\|\/)core(\\|\/)@angular/,
root('./src'), root('./src'), {}
{}
), ),
/** /**