diff --git a/public/docs/_examples/upgrade-phonecat-1-typescript/ts/karma.conf.ng1.js b/public/docs/_examples/upgrade-phonecat-1-typescript/ts/karma.conf.ng1.js index dc829d1983..74aacea538 100644 --- a/public/docs/_examples/upgrade-phonecat-1-typescript/ts/karma.conf.ng1.js +++ b/public/docs/_examples/upgrade-phonecat-1-typescript/ts/karma.conf.ng1.js @@ -5,11 +5,10 @@ module.exports = function(config) { basePath: './app', files: [ - 'https://code.angularjs.org/1.5.5/angular.js', - 'https://code.angularjs.org/1.5.5/angular-animate.js', - 'https://code.angularjs.org/1.5.5/angular-resource.js', - 'https://code.angularjs.org/1.5.5/angular-route.js', - 'https://code.angularjs.org/1.5.5/angular-mocks.js', + 'https://unpkg.com/angular@1.5.8/angular.js', + 'https://unpkg.com/angular-resource@1.5.8/angular-resource.js', + 'https://unpkg.com/angular-route@1.5.8/angular-route.js', + 'https://unpkg.com/angular-mocks@1.5.8/angular-mocks.js', '**/*.module.js', '*!(.module|.spec).js', '!(bower_components)/**/*!(.module|.spec).js', @@ -20,11 +19,10 @@ module.exports = function(config) { frameworks: ['jasmine'], - browsers: ['Chrome', 'Firefox'], + browsers: ['Chrome'], plugins: [ 'karma-chrome-launcher', - 'karma-firefox-launcher', 'karma-jasmine' ] diff --git a/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/example-config.json b/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/example-config.json index 6af3884d8d..e69de29bb2 100644 --- a/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/example-config.json +++ b/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/example-config.json @@ -1,3 +0,0 @@ -{ - "unittesting": true -} diff --git a/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/karma-test-shim.1.js b/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/karma-test-shim.1.js index 19fcc89fe9..081a1ddcd9 100644 --- a/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/karma-test-shim.1.js +++ b/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/karma-test-shim.1.js @@ -19,6 +19,10 @@ function isSpecFile(path) { return /\.spec\.(.*\.)?js$/.test(path); } +function isModuleFile(path) { + return /\.module\.js$/.test(path); +} + function isBuiltFile(path) { return isJsFile(path) && (path.substr(0, builtPath.length) == builtPath); } @@ -27,8 +31,11 @@ var allSpecFiles = Object.keys(window.__karma__.files) .filter(isSpecFile) .filter(isBuiltFile); +var allModuleFiles = Object.keys(window.__karma__.files) + .filter(isModuleFile); + System.config({ - baseURL: '/base', + baseURL: 'base', // Extend usual application package list with test folder packages: { 'testing': { main: 'index.js', defaultExtension: 'js' } }, @@ -80,10 +87,12 @@ function initTestBed(){ // Import all spec files and start karma function initTesting () { - return Promise.all( - allSpecFiles.map(function (moduleName) { + var promises = allModuleFiles.map(function (moduleName) { return System.import(moduleName); }) - ) + .concat(allSpecFiles.map(function (moduleName) { + return System.import(moduleName); + })); + return Promise.all(promises) .then(__karma__.start, __karma__.error); } diff --git a/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/karma.conf.ng1.js b/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/karma.conf.ng1.js index 3decfbdd3e..1db2f2039d 100644 --- a/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/karma.conf.ng1.js +++ b/public/docs/_examples/upgrade-phonecat-2-hybrid/ts/karma.conf.ng1.js @@ -1,19 +1,32 @@ -//jshint strict: false +// #docregion module.exports = function(config) { - config.set({ - // #docregion basepath - basePath: './', - // #enddocregion basepath + var appBase = 'app/'; // transpiled app JS and map files + var appSrcBase = 'app/'; // app source TS files + var appAssets = 'base/app/'; // component assets fetched by Angular's compiler - files: [ - 'https://code.angularjs.org/1.5.5/angular.js', - 'https://code.angularjs.org/1.5.5/angular-animate.js', - 'https://code.angularjs.org/1.5.5/angular-resource.js', - 'https://code.angularjs.org/1.5.5/angular-route.js', - 'https://code.angularjs.org/1.5.5/angular-mocks.js', + var testBase = 'testing/'; // transpiled test JS and map files + var testSrcBase = 'testing/'; // test source TS files + + config.set({ + basePath: '', + frameworks: ['jasmine'], + plugins: [ + require('karma-jasmine'), + require('karma-chrome-launcher'), + require('karma-jasmine-html-reporter'), // click "Debug" in browser to see it + require('karma-htmlfile-reporter') // crashing w/ strange socket error + ], - // #docregion files + customLaunchers: { + // From the CLI. Not used here but interesting + // chrome setup for travis CI using chromium + Chrome_travis_ci: { + base: 'Chrome', + flags: ['--no-sandbox'] + } + }, + files: [ // System.js for module loading 'node_modules/systemjs/dist/system.src.js', @@ -30,45 +43,66 @@ module.exports = function(config) { 'node_modules/zone.js/dist/async-test.js', 'node_modules/zone.js/dist/fake-async-test.js', - // RxJs. + // Angular 1 needed for hybrid apps + 'https://unpkg.com/angular@1.5.9/angular.js', + 'https://unpkg.com/angular-route@1.5.9/angular-route.js', + + // RxJs { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false }, { pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false }, - // Angular 2 itself and the testing library + // Paths loaded via module imports: + // Angular itself {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false}, {pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false}, {pattern: 'systemjs.config.js', included: false, watched: false}, - 'karma-test-shim.js', + {pattern: 'systemjs.config.extras.js', included: false, watched: false}, + 'karma-test-shim.1.js', - {pattern: 'app/**/*.module.js', included: false, watched: true}, - {pattern: 'app/*!(.module|.spec).js', included: false, watched: true}, - {pattern: 'app/!(bower_components)/**/*!(.module|.spec).js', included: false, watched: true}, - {pattern: 'app/**/*.spec.js', included: false, watched: true}, + // transpiled application & spec code paths loaded via module imports + {pattern: appBase + '**/*.js', included: false, watched: true}, + {pattern: testBase + '**/*.js', included: false, watched: true}, - {pattern: '**/*.html', included: false, watched: true}, - // #enddocregion files + + // Asset (HTML & CSS) paths loaded via Angular's component compiler + // (these paths need to be rewritten, see proxies section) + {pattern: appBase + '**/*.html', included: false, watched: true}, + {pattern: appBase + '**/*.css', included: false, watched: true}, + + // Paths for debugging with source maps in dev tools + {pattern: appSrcBase + '**/*.ts', included: false, watched: false}, + {pattern: appBase + '**/*.js.map', included: false, watched: false}, + {pattern: testSrcBase + '**/*.ts', included: false, watched: false}, + {pattern: testBase + '**/*.js.map', included: false, watched: false} ], - // #docregion html - // proxied base paths for loading assets + // Proxied base paths for loading assets proxies: { // required for component assets fetched by Angular's compiler - "/phone-detail": '/base/app/phone-detail', - "/phone-list": '/base/app/phone-list' + "/app/": appAssets }, - // #enddocregion html - autoWatch: true, - - frameworks: ['jasmine'], + exclude: [], + preprocessors: {}, + // disabled HtmlReporter; suddenly crashing w/ strange socket error + reporters: ['progress', 'kjhtml'],//'html'], - browsers: ['Chrome'], + // HtmlReporter configuration + htmlReporter: { + // Open this file to see results in browser + outputFile: '_test-output/tests.html', - plugins: [ - 'karma-chrome-launcher', - 'karma-jasmine' - ] + // Optional + pageTitle: 'Unit Tests', + subPageTitle: __dirname + }, - }); -}; + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: true, + browsers: ['Chrome'], + singleRun: false + }) +} \ No newline at end of file diff --git a/public/docs/_examples/upgrade-phonecat-3-final/ts/karma.conf.ng1.js b/public/docs/_examples/upgrade-phonecat-3-final/ts/karma.conf.ng1.js deleted file mode 100644 index 3decfbdd3e..0000000000 --- a/public/docs/_examples/upgrade-phonecat-3-final/ts/karma.conf.ng1.js +++ /dev/null @@ -1,74 +0,0 @@ -//jshint strict: false -module.exports = function(config) { - config.set({ - - // #docregion basepath - basePath: './', - // #enddocregion basepath - - files: [ - 'https://code.angularjs.org/1.5.5/angular.js', - 'https://code.angularjs.org/1.5.5/angular-animate.js', - 'https://code.angularjs.org/1.5.5/angular-resource.js', - 'https://code.angularjs.org/1.5.5/angular-route.js', - 'https://code.angularjs.org/1.5.5/angular-mocks.js', - - // #docregion files - // System.js for module loading - 'node_modules/systemjs/dist/system.src.js', - - // Polyfills - 'node_modules/core-js/client/shim.js', - 'node_modules/reflect-metadata/Reflect.js', - - // zone.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', - - // RxJs. - { pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false }, - { pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false }, - - // Angular 2 itself and the testing library - {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false}, - {pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false}, - - {pattern: 'systemjs.config.js', included: false, watched: false}, - 'karma-test-shim.js', - - {pattern: 'app/**/*.module.js', included: false, watched: true}, - {pattern: 'app/*!(.module|.spec).js', included: false, watched: true}, - {pattern: 'app/!(bower_components)/**/*!(.module|.spec).js', included: false, watched: true}, - {pattern: 'app/**/*.spec.js', included: false, watched: true}, - - {pattern: '**/*.html', included: false, watched: true}, - // #enddocregion files - ], - - // #docregion html - // proxied base paths for loading assets - proxies: { - // required for component assets fetched by Angular's compiler - "/phone-detail": '/base/app/phone-detail', - "/phone-list": '/base/app/phone-list' - }, - // #enddocregion html - - autoWatch: true, - - frameworks: ['jasmine'], - - browsers: ['Chrome'], - - plugins: [ - 'karma-chrome-launcher', - 'karma-jasmine' - ] - - }); -};