|
1 | 1 | module.exports = function(config) {
|
2 |
| - config.set({ |
3 | 2 |
|
4 |
| - basePath: '', |
| 3 | + var appBase = 'app/'; // transpiled app JS files |
| 4 | + var appAssets ='base/app/'; // component assets fetched by Angular's compiler |
5 | 5 |
|
| 6 | + config.set({ |
| 7 | + basePath: '', |
6 | 8 | frameworks: ['jasmine'],
|
| 9 | + plugins: [ |
| 10 | + require('karma-jasmine'), |
| 11 | + require('karma-chrome-launcher'), |
| 12 | + require('karma-htmlfile-reporter') |
| 13 | + ], |
| 14 | + |
| 15 | + customLaunchers: { |
| 16 | + // From the CLI. Not used here but interesting |
| 17 | + // chrome setup for travis CI using chromium |
| 18 | + Chrome_travis_ci: { |
| 19 | + base: 'Chrome', |
| 20 | + flags: ['--no-sandbox'] |
| 21 | + } |
| 22 | + }, |
7 | 23 |
|
8 | 24 | files: [
|
9 |
| - // paths loaded by Karma |
10 |
| - {pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true}, |
11 |
| - {pattern: 'node_modules/angular2/bundles/angular2.js', included: true, watched: true}, |
12 |
| - {pattern: 'node_modules/angular2/bundles/testing.js', included: true, watched: true}, |
13 |
| - {pattern: 'karma-test-shim.js', included: true, watched: true}, |
14 |
| - {pattern: 'app/test/*.js', included: true, watched: true}, |
| 25 | + // Angular and shim libraries loaded by Karma |
| 26 | + { pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: true, watched: true }, |
| 27 | + { pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true }, |
| 28 | + { pattern: 'node_modules/es6-shim/es6-shim.js', included: true, watched: true }, |
| 29 | + { pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', included: true, watched: true }, |
| 30 | + { pattern: 'node_modules/rxjs/bundles/Rx.js', included: true, watched: true }, |
| 31 | + { pattern: 'node_modules/angular2/bundles/angular2.js', included: true, watched: true }, |
| 32 | + { pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, watched: true }, |
15 | 33 |
|
16 |
| - // paths loaded via module imports |
17 |
| - {pattern: 'app/**/*.js', included: false, watched: true}, |
| 34 | + // External libraries loaded by Karma |
| 35 | + { pattern: 'node_modules/angular2/bundles/http.dev.js', included: true, watched: true }, |
| 36 | + { pattern: 'node_modules/angular2/bundles/router.dev.js', included: true, watched: true }, |
| 37 | + { pattern: 'node_modules/a2-in-memory-web-api/web-api.js', included: true, watched: true }, |
18 | 38 |
|
19 |
| - // paths loaded via Angular's component compiler |
| 39 | + // Configures module loader w/ app and specs, then launch karma |
| 40 | + { pattern: 'karma-test-shim.js', included: true, watched: true }, |
| 41 | + |
| 42 | + // transpiled application & spec code paths loaded via module imports |
| 43 | + {pattern: appBase + '**/*.js', included: false, watched: true}, |
| 44 | + |
| 45 | + // asset (HTML & CSS) paths loaded via Angular's component compiler |
20 | 46 | // (these paths need to be rewritten, see proxies section)
|
21 |
| - {pattern: 'app/**/*.html', included: false, watched: true}, |
22 |
| - {pattern: 'app/**/*.css', included: false, watched: true}, |
| 47 | + {pattern: appBase + '**/*.html', included: false, watched: true}, |
| 48 | + {pattern: appBase + '**/*.css', included: false, watched: true}, |
23 | 49 |
|
24 |
| - // paths to support debugging with source maps in dev tools |
25 |
| - {pattern: 'app/**/*.ts', included: false, watched: false}, |
26 |
| - {pattern: 'app/**/*.js.map', included: false, watched: false} |
| 50 | + // paths for debugging with source maps in dev tools |
| 51 | + {pattern: appBase + '**/*.ts', included: false, watched: false}, |
| 52 | + {pattern: appBase + '**/*.js.map', included: false, watched: false} |
27 | 53 | ],
|
28 | 54 |
|
29 |
| - // proxied base paths |
| 55 | + // proxied base paths for loading assets |
30 | 56 | proxies: {
|
31 |
| - // required for component assests fetched by Angular's compiler |
32 |
| - "/app/": "/base/app/" |
| 57 | + // required for component assets fetched by Angular's compiler |
| 58 | + "/app/": appAssets |
| 59 | + }, |
| 60 | + |
| 61 | + exclude: [], |
| 62 | + preprocessors: {}, |
| 63 | + reporters: ['progress', 'html'], |
| 64 | + |
| 65 | + // HtmlReporter configuration |
| 66 | + htmlReporter: { |
| 67 | + // Open this file to see results in browser |
| 68 | + outputFile: '_test-output/tests.html', |
| 69 | + |
| 70 | + // Optional |
| 71 | + pageTitle: 'Unit Tests', |
| 72 | + subPageTitle: __dirname |
33 | 73 | },
|
34 | 74 |
|
35 |
| - reporters: ['progress'], |
36 |
| - port: 9877, |
| 75 | + port: 9876, |
37 | 76 | colors: true,
|
38 | 77 | logLevel: config.LOG_INFO,
|
39 | 78 | autoWatch: true,
|
40 | 79 | browsers: ['Chrome'],
|
41 |
| - singleRun: true |
| 80 | + singleRun: false |
42 | 81 | })
|
43 | 82 | }
|
0 commit comments