Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

docs(upgrade): fix testing #2865

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]/angular.js',
'https://unpkg.com/[email protected]/angular-resource.js',
'https://unpkg.com/[email protected]/angular-route.js',
'https://unpkg.com/[email protected]/angular-mocks.js',
'**/*.module.js',
'*!(.module|.spec).js',
'!(bower_components)/**/*!(.module|.spec).js',
Expand All @@ -20,11 +19,10 @@ module.exports = function(config) {

frameworks: ['jasmine'],

browsers: ['Chrome', 'Firefox'],
browsers: ['Chrome'],

plugins: [
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-jasmine'
]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
{
"unittesting": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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' } },

Expand Down Expand Up @@ -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);
}
106 changes: 70 additions & 36 deletions public/docs/_examples/upgrade-phonecat-2-hybrid/ts/karma.conf.ng1.js
Original file line number Diff line number Diff line change
@@ -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',

Expand All @@ -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/[email protected]/angular.js',
'https://unpkg.com/[email protected]/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
})
}

This file was deleted.