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);