From ca29eabd19a82e4b52e0950d596ea1a9010cfe0f Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Mon, 13 Feb 2017 11:57:24 +0000 Subject: [PATCH] fix(@angular/cli): include polyfills before scripts in ng test Fix #4545 Close #4656 --- packages/@angular/cli/plugins/karma.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/@angular/cli/plugins/karma.js b/packages/@angular/cli/plugins/karma.js index f8f2f5b7e1..252a793caa 100644 --- a/packages/@angular/cli/plugins/karma.js +++ b/packages/@angular/cli/plugins/karma.js @@ -67,19 +67,6 @@ const init = (config) => { .map((file) => config.preprocessors[file]) .map((arr) => arr.splice(arr.indexOf('@angular/cli'), 1, 'webpack', 'sourcemap')); - // Add polyfills file - if (appConfig.polyfills) { - const polyfillsFile = path.resolve(appRoot, appConfig.polyfills); - const polyfillsPattern = { - pattern: polyfillsFile, - included: true, - served: true, - watched: true - } - Array.prototype.unshift.apply(config.files, [polyfillsPattern]); - config.preprocessors[polyfillsFile] = ['webpack', 'sourcemap']; - } - // Add global scripts if (appConfig.scripts && appConfig.scripts.length > 0) { const globalScriptPatterns = appConfig.scripts @@ -98,6 +85,19 @@ const init = (config) => { // karma already has a reference to the existing array. Array.prototype.unshift.apply(config.files, globalScriptPatterns); } + + // Add polyfills file before everything else + if (appConfig.polyfills) { + const polyfillsFile = path.resolve(appRoot, appConfig.polyfills); + const polyfillsPattern = { + pattern: polyfillsFile, + included: true, + served: true, + watched: true + } + Array.prototype.unshift.apply(config.files, [polyfillsPattern]); + config.preprocessors[polyfillsFile] = ['webpack', 'sourcemap']; + } } init.$inject = ['config'];