From a2542790b9009b4e4c07fd2deffb9562dc038e79 Mon Sep 17 00:00:00 2001 From: Swagata Prateek Date: Thu, 6 Apr 2017 19:04:37 +0200 Subject: [PATCH] Deleted the test tasks, we slowly need to move it to Angular CLI or webpack since that is the thing to do here --- config/gulp/tasks/build.js | 2 +- config/gulp/tasks/test.js | 70 ------------------------ config/test/karma-test-shim.js | 40 -------------- config/test/karma.conf.js | 97 ---------------------------------- config/test/protractor.conf.js | 23 -------- src/app/app.component.spec.ts | 51 ------------------ 6 files changed, 1 insertion(+), 282 deletions(-) delete mode 100644 config/gulp/tasks/test.js delete mode 100644 config/test/karma-test-shim.js delete mode 100644 config/test/karma.conf.js delete mode 100644 config/test/protractor.conf.js delete mode 100644 src/app/app.component.spec.ts diff --git a/config/gulp/tasks/build.js b/config/gulp/tasks/build.js index a0a46a0..a546ea5 100644 --- a/config/gulp/tasks/build.js +++ b/config/gulp/tasks/build.js @@ -16,7 +16,7 @@ var envVars = require('../utils/env-vars'); require('@ngstarter/systemjs-extension')(config); gulp.task('build', function (done) { - runSequence('test', 'build-systemjs', 'build-assets', done); + runSequence('build-systemjs', 'build-assets', done); }); /* Concat and minify/uglify all css, js, and copy fonts */ diff --git a/config/gulp/tasks/test.js b/config/gulp/tasks/test.js deleted file mode 100644 index b3a8596..0000000 --- a/config/gulp/tasks/test.js +++ /dev/null @@ -1,70 +0,0 @@ -var gulp = require('gulp'); -var util = require('gulp-util'); -var config = require('../config')(); -var Server = require('karma').Server; -var gulpProtractor = require('gulp-protractor'); -var remapIstanbul = require('remap-istanbul/lib/gulpRemapIstanbul'); -var runSequence = require('run-sequence'); -var argv = require('yargs') - .alias('w', 'watch') - .argv; - -gulp.task('test', ['clean-report', 'unit-test']); - -gulp.task('unit-test', ['tsc'], function (done) { - var watch = argv.watch || false; - - runSequence(['html', 'css'], copyComponentFilesDone); - - if (watch) { - runSequence(['watch-ts', 'watch-html', 'watch-css']); - console.log('=== Unit Test Watch Mode ==='); - console.log('- It will autowatch the changed files and re-run the test'); - console.log('- Press Cmd/Ctrl + C to exit and get the coverage result'); - console.log('- Press Cmd/Ctrl + C again to close the TSC watch.'); - } - - function copyComponentFilesDone() { - new Server({ - configFile: __dirname + '/../../test/karma.conf.js', - singleRun: !watch - }, karmaDone).start(); - } - - function karmaDone (exitCode) { - remapCoverage(done, exitCode); - } -}); - -gulp.task('e2e', ['e2e-test']); -gulp.task('driver-update', gulpProtractor['webdriver_update']); -gulp.task('e2e-test', ['driver-update'], function () { - gulp.src(config.e2e + '**/*.spec.ts') - .pipe(gulpProtractor.protractor({ - configFile: 'config/test/protractor.conf.js', - args: ['--baseUrl', config.e2eConfig.seleniumTarget] - })) - .on('error', function(e) { - util.log('Error running E2E testing'); - process.exit(1); - }); -}); - -function remapCoverage (done, exitCode) { - util.log('Remapping coverage to TypeScript format...'); - gulp.src(config.report.path + 'report-json/coverage-final.json') - .pipe(remapIstanbul({ - basePath: config.src, - reports: { - 'lcovonly': config.report.path + 'remap/lcov.info', - 'json': config.report.path + 'remap/coverage.json', - 'html': config.report.path + 'remap/html-report', - 'text-summary': config.report.path + 'remap/text-summary.txt' - } - })) - .on('finish', function () { - util.log('Test Done with exit code: ' + exitCode); - done(exitCode); - util.log('Remapping done! View the result in report/remap/html-report'); - }); -} diff --git a/config/test/karma-test-shim.js b/config/test/karma-test-shim.js deleted file mode 100644 index f7b1976..0000000 --- a/config/test/karma-test-shim.js +++ /dev/null @@ -1,40 +0,0 @@ -// Turn on full stack traces in errors to help debugging -Error.stackTraceLimit=Infinity; - -jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000; - -// Cancel Karma's synchronous start, -// we will call `__karma__.start()` later, once all the specs are loaded. -__karma__.loaded = function() {}; - -System.import('test/test-helpers/setup') -.then(function() { - return Promise.all( - Object.keys(window.__karma__.files) - .filter(onlySpecFiles) - .map(file2moduleName) - .map(importModules) - ); -}) -.then(function() { - __karma__.start(); -}, function(error) { - __karma__.error(error.name + ": " + error.message); -}); - -// Filter spec files -function onlySpecFiles(path) { - return /\.spec\.js$/.test(path); -} - -// Normalize paths to module names. -function file2moduleName(filePath) { - return filePath.replace(/\\/g, '/') - .replace(/^\/base\//, '') - .replace(/\.js/, ''); -} - -// Import module path -function importModules(path) { - return System.import(path); -} diff --git a/config/test/karma.conf.js b/config/test/karma.conf.js deleted file mode 100644 index af04eaa..0000000 --- a/config/test/karma.conf.js +++ /dev/null @@ -1,97 +0,0 @@ -module.exports = function(config) { - var gulpConfig = require('../gulp/config')(); - - /** - * List of npm packages that imported via `import` syntax - */ - var dependencies = [ - '@angular', - 'lodash', - 'rxjs' - ]; - - var configuration = { - basePath: '../../', - - frameworks: ['jasmine'], - browsers: ['PhantomJS'], - reporters: ['progress', 'coverage'], - - preprocessors: {}, - - // Generate json used for remap-istanbul - coverageReporter: { - dir: 'report/', - reporters: [ - { type: 'json', subdir: 'report-json' } - ] - }, - - files: [ - 'node_modules/core-js/client/shim.min.js', - 'node_modules/zone.js/dist/zone.js', - 'node_modules/zone.js/dist/long-stack-trace-zone.js', - 'node_modules/zone.js/dist/proxy.js', - 'node_modules/zone.js/dist/sync-test.js', - 'node_modules/zone.js/dist/jasmine-patch.js', - 'node_modules/zone.js/dist/async-test.js', - 'node_modules/zone.js/dist/fake-async-test.js', - 'node_modules/systemjs/dist/system.src.js' - ], - - // proxied base paths - proxies: { - // required for component assests fetched by Angular's compiler - "/src/": "/base/src/", - "/app/": "/base/src/app/", - "/tmp/": "/base/src/tmp/", - "/node_modules/": "/base/node_modules/" - }, - - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: true - }; - - configuration.preprocessors[gulpConfig.tmpApp + '**/!(*.spec)+(.js)'] = ['coverage']; - configuration.preprocessors[gulpConfig.tmpApp + '**/*.js'] = ['sourcemap']; - configuration.preprocessors[gulpConfig.tmpTest + '**/*.js'] = ['sourcemap']; - - var files = [ - gulpConfig.tmpTest + 'test-helpers/global/**/*.js', - gulpConfig.src + 'systemjs.conf.js', - 'config/test/karma-test-shim.js', - createFilePattern(gulpConfig.tmpApp + '**/*.js', { included: false }), - createFilePattern(gulpConfig.tmpTest + 'test-helpers/*.js', { included: false }), - createFilePattern(gulpConfig.app + '**/*.html', { included: false }), - createFilePattern(gulpConfig.tmpApp + '**/*.html', { included: false }), - createFilePattern(gulpConfig.app + '**/*.css', { included: false }), - createFilePattern(gulpConfig.app + '**/*.ts', { included: false, watched: false }), - createFilePattern(gulpConfig.tmpApp + '**/*.js.map', { included: false, watched: false }) - ]; - - configuration.files = configuration.files.concat(files); - - dependencies.forEach(function(key) { - configuration.files.push({ - pattern: 'node_modules/' + key + '/**/!(*.spec)+(.js)', - included: false, - watched: false - }); - }); - - if (process.env.APPVEYOR) { - configuration.browsers = ['IE']; - configuration.singleRun = true; - configuration.browserNoActivityTimeout = 90000; // Note: default value (10000) is not enough - } - - config.set(configuration); - - // Helpers - function createFilePattern(path, config) { - config.pattern = path; - return config; - } -} diff --git a/config/test/protractor.conf.js b/config/test/protractor.conf.js deleted file mode 100644 index 20d91ed..0000000 --- a/config/test/protractor.conf.js +++ /dev/null @@ -1,23 +0,0 @@ -require('ts-node/register'); - -var glob = require('glob'); -var seleniumPath = '../node_modules/gulp-protractor/node_modules/protractor/selenium/'; -var seleniumJarPath = ''; - -glob(seleniumPath + '*.jar', - function(err, files) { - seleniumJarPath = files[0]; - }); - -exports.config = { - seleniumServerJar: seleniumJarPath, - capabilities: { - 'browserName': 'chrome' - }, - jasmineNodeOpts: { - showColors: true, - defaultTimeoutInterval: 60000 - }, - allScriptsTimeout: 30000, - useAllAngular2AppRoots: true -}; diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts deleted file mode 100644 index 2034f0a..0000000 --- a/src/app/app.component.spec.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { - RouterTestingModule -} from '@angular/router/testing'; -import { - async, - TestBed, - ComponentFixture -} from '@angular/core/testing'; -import { provideRoutes, Routes, RouterModule } from '@angular/router'; -import { Component } from '@angular/core'; - -import { AppComponent } from './app.component'; - -@Component({ - selector: 'as-test-cmp', - template: '
Hello test
' -}) -class TestRouterComponent { -} - -let config: Routes = [ - { - path: '', component: TestRouterComponent - } -]; - -describe('AppComponent', () => { - beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [ - TestRouterComponent, - AppComponent - ], - imports: [RouterTestingModule, RouterModule], - providers: [provideRoutes(config)] - }); - }); - - it('should have title Hello world', async(() => { - TestBed.compileComponents().then(() => { - let fixture: ComponentFixture; - fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - - let compiled = fixture.debugElement.nativeElement; - expect(compiled).toBeDefined(); - // TODO: find a way to compile the routed component - // expect(compiled.querySelector('div.title')).toMatch('Hello world'); - }); - })); -});