From 0a32f853c890fc1ca349b1258ee2406e8fb694d3 Mon Sep 17 00:00:00 2001 From: Keen Yee Liau Date: Tue, 10 Nov 2020 11:52:16 -0800 Subject: [PATCH] fix(@angular-devkit/build-angular): Downgrade Karma to 5.1.x There's a bug in Karma 5.2.x that causes unit tests to fail when they should not. It was supposed to be fixed in https://github.com/karma-runner/karma/pull/3565 but CI still failed, blocking the release of Karma. In order to mitigate this, we temporarily downgrade Karma back to 5.1.x A side-effect of this is that coverage tests that uses karma-coverage and exceeds the threshold will not fail, because karma-coverage requires Karma 5.2.x. We expect this to be fixed very soon. --- packages/angular_devkit/build_angular/package.json | 4 ++-- .../angular_devkit/build_angular/src/webpack/plugins/karma.ts | 1 + .../schematics/angular/workspace/files/package.json.template | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/angular_devkit/build_angular/package.json b/packages/angular_devkit/build_angular/package.json index 20423e320d83..fd47edf3f6d3 100644 --- a/packages/angular_devkit/build_angular/package.json +++ b/packages/angular_devkit/build_angular/package.json @@ -13,7 +13,7 @@ "@angular-devkit/core": "0.0.0", "@babel/core": "7.12.3", "@babel/generator": "7.12.1", - "@babel/plugin-transform-runtime": "7.12.1", + "@babel/plugin-transform-runtime": "7.12.1", "@babel/preset-env": "7.12.1", "@babel/runtime": "7.12.1", "@babel/template": "7.10.4", @@ -80,7 +80,7 @@ "peerDependencies": { "@angular/compiler-cli": "^11.0.0 || ^11.0.0-next", "@angular/localize": "^11.0.0 || ^11.0.0-next", - "karma": "^5.2.0", + "karma": "~5.1.0", "ng-packagr": "^11.0.0 || ^11.0.0-next", "protractor": "^7.0.0", "tslint": "^6.1.0", diff --git a/packages/angular_devkit/build_angular/src/webpack/plugins/karma.ts b/packages/angular_devkit/build_angular/src/webpack/plugins/karma.ts index ae7876f027ac..5caaf4690f30 100644 --- a/packages/angular_devkit/build_angular/src/webpack/plugins/karma.ts +++ b/packages/angular_devkit/build_angular/src/webpack/plugins/karma.ts @@ -99,6 +99,7 @@ const init: any = (config: any, emitter: any, customFileHandlers: any) => { const hasIstanbulReporter = reporters.includes('coverage-istanbul'); if (hasCoveragePlugin && !hasCoverageReporter) { reporters.push('coverage'); + logger.warn(`There is a known issue with Karma and karma-coverage. Tests that exceed the coverage threshold will not fail. This will be fixed in Karma 5.2.x soon.`) } else if (hasIstanbulPlugin && !hasIstanbulReporter) { // coverage-istanbul is deprecated in favor of karma-coverage diff --git a/packages/schematics/angular/workspace/files/package.json.template b/packages/schematics/angular/workspace/files/package.json.template index c203c22c86e9..c03a5e94bf28 100644 --- a/packages/schematics/angular/workspace/files/package.json.template +++ b/packages/schematics/angular/workspace/files/package.json.template @@ -30,7 +30,7 @@ "codelyzer": "^6.0.0", "jasmine-core": "~3.6.0", "jasmine-spec-reporter": "~5.0.0", - "karma": "~5.2.0", + "karma": "~5.1.0", "karma-chrome-launcher": "~3.1.0", "karma-coverage": "~2.0.3", "karma-jasmine": "~4.0.0",