@yolkai/nx-schematics
Version:
36 lines (31 loc) • 1.27 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
exports.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();
`);
}
};