import * as fs from 'fs'; export default { description: 'Update test.js', run: () => { fs.writeFileSync( 'test.js', ` // This file is required by karma.conf.js and loads recursively all the .spec and framework files require('zone.js/dist/zone-testing'); const getTestBed = require('@angular/core/testing').getTestBed; const BrowserDynamicTestingModule = require('@angular/platform-browser-dynamic/testing').BrowserDynamicTestingModule; const platformBrowserDynamicTesting = require('@angular/platform-browser-dynamic/testing').platformBrowserDynamicTesting; // Prevent Karma from running prematurely. __karma__.loaded = function () {}; // First, initialize the Angular testing environment. getTestBed().initTestEnvironment( BrowserDynamicTestingModule, platformBrowserDynamicTesting() ); // Then we find all the tests. const contextApps = require.context('./apps', true, /\\.spec\\.ts$/); // And load the modules. contextApps.keys().map(contextApps); const contextLibs = require.context('./libs', true, /\\.spec\\.ts$/); // And load the modules. contextLibs.keys().map(contextLibs); // Finally, start Karma to run the tests. __karma__.start(); ` ); } };