angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Previously Working Test Suite Throws Error after Upgrade to 15.0.0

Open ianfmc opened this issue 3 years ago • 6 comments

Command

test

Is this a regression?

  • [X] Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

14.2.9

Description

Previously working angular test suite now throws error. 0 tests are executed. Error is below:

✔ Browser application bundle generation complete.
✔ Browser application bundle generation complete.
Chrome 107.0.0.0 (Mac OS 10.15.7) ERROR
  An error was thrown in afterAll
  Uncaught TypeError: __webpack_require__(...).context is not a function
  TypeError: __webpack_require__(...).context is not a function
      at Module.4289 (http://localhost:9876/_karma_webpack_/webpack:/src/test.ts:18:25)
      at __webpack_require__ (http://localhost:9876/_karma_webpack_/webpack:/webpack/bootstrap:19:1)
      at __webpack_exec__ (http://localhost:9876/_karma_webpack_/main.js:10471:48)
      at http://localhost:9876/_karma_webpack_/main.js:10472:54
      at Function.__webpack_require__.O (http://localhost:9876/_karma_webpack_/webpack:/webpack/runtime/chunk loaded:23:1)
      at http://localhost:9876/_karma_webpack_/main.js:10473:56
      at webpackJsonpCallback (http://localhost:9876/_karma_webpack_/webpack:/webpack/runtime/jsonp chunk loading:34:1)
      at http://localhost:9876/_karma_webpack_/main.js:1:75
Chrome 107.0.0.0 (Mac OS 10.15.7): Executed 0 of 0 ERROR (0 secs / 0 secs)
Chrome 107.0.0.0 (Mac OS 10.15.7) ERROR
  An error was thrown in afterAll
  Uncaught TypeError: __webpack_require__(...).context is not a function
  TypeError: __webpack_require__(...).context is not a function
      at Module.4289 (http://localhost:9876/_karma_webpack_/webpack:/src/test.ts:18:25)
      at __webpack_require__ (http://localhost:9876/_karma_webpack_/webpack:/webpack/bootstrap:19:1)
      at __webpack_exec__ (http://localhost:9876/_karma_webpack_/main.js:10471:48)
      at http://localhost:9876/_karma_webpack_/main.js:10472:54
      at Function.__webpack_require__.O (http://localhost:9876/_karma_webpack_/webpack:/webpack/runtime/chunk loaded:23:1)
      at http://localhost:9876/_karma_webpack_/main.js:10473:56
      at webpackJsonpCallback (http://localhost:9876/_karma_webpack_/webpack:/webpack/runtime/jsonp chunk loading:34:1)
Chrome 107.0.0.0 (Mac OS 10.15.7): Executed 0 of 0 ERROR (0.005 secs / 0 secs)

Minimal Reproduction

To duplicate:

  1. ng test

Packages Added (package.json):

{
  "name": "elyc-online",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "node --max_old_space_size=8196 node_modules/@angular/cli/bin/ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "browser": {
    "crypto": false
  },
  "private": true,
  "dependencies": {
    "@angular-material-extensions/password-strength": "^11.0.1",
    "@angular/animations": "^15.0.0",
    "@angular/cdk": "^15.0.0",
    "@angular/common": "^15.0.0",
    "@angular/compiler": "^15.0.0",
    "@angular/core": "^15.0.0",
    "@angular/forms": "^15.0.0",
    "@angular/material": "^15.0.0",
    "@angular/platform-browser": "^15.0.0",
    "@angular/platform-browser-dynamic": "^15.0.0",
    "@angular/router": "^15.0.0",
    "@aws-amplify/api-graphql": "^3.0.2",
    "@aws-amplify/cli": "^10.5.0",
    "@aws-amplify/core": "^5.0.2",
    "@aws-amplify/ui-angular": "^3.0.0",
    "@aws-sdk/client-cognito-identity-provider": "^3.212.0",
    "@aws-sdk/client-s3": "^3.212.0",
    "@aws-sdk/s3-request-presigner": "^3.212.0",
    "@stripe/stripe-js": "^1.44.1",
    "@types/stripe-checkout": "^1.0.4",
    "@types/stripe-v3": "^3.1.27",
    "aws-amplify": "^5.0.2",
    "aws-amplify-angular": "^6.0.60",
    "aws-rum-web": "^1.12.0",
    "hammerjs": "^2.0.8",
    "libphonenumber-js": "^1.10.14",
    "rxjs": "^7.5.7",
    "stripe": "^11.0.0",
    "tslib": "^2.4.1",
    "zone.js": "~0.12.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^15.0.0",
    "@angular/cli": "^15.0.0",
    "@angular/compiler-cli": "^15.0.0",
    "@angular/language-service": "^15.0.0",
    "@types/jasmine": "^4.3.0",
    "@types/jasminewd2": "^2.0.10",
    "@types/node": "^18.11.9",
    "codelyzer": "^6.0.2",
    "jasmine-core": "^4.5.0",
    "jasmine-spec-reporter": "^7.0.0",
    "karma": "^6.4.1",
    "karma-chrome-launcher": "^3.1.1",
    "karma-coverage-istanbul-reporter": "^3.0.3",
    "karma-jasmine": "^5.1.0",
    "karma-jasmine-html-reporter": "^2.0.0",
    "protractor": "~7.0.0",
    "schematics-scss-migrate": "^1.3.15",
    "ts-node": "~10.9.1",
    "tslint": "~5.20.1",
    "typescript": "~4.8.3"
  }
}

Related Code Changes:

Updated CLI to 15.0.0

Exception or Error

0 Tests are run. Should run a suite of 53 tests.

Your Environment

- Angular: 15.0.0
- CDK/Material: 15.0.0 
- Browser(s): Chrome Version 107.0.5304.110 (Official Build) (x86_64)
- Operating System (e.g. Windows, macOS, Ubuntu): MacOS 12.5.2


Angular CLI: 15.0.0
Node: 16.11.0
Package Manager: npm 8.0.0
OS: darwin x64

Angular: 15.0.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, language-service, material, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1500.0
@angular-devkit/build-angular   15.0.0
@angular-devkit/core            15.0.0
@angular-devkit/schematics      15.0.0
@schematics/angular             15.0.0
rxjs                            7.5.7
typescript                      4.8.4


### Anything else relevant?

_No response_

ianfmc avatar Nov 19 '22 20:11 ianfmc

Please note: I have created a minimal repository using ng new. The same error occurs without modifying any generated code.

ianfmc avatar Nov 20 '22 01:11 ianfmc

Try to remove node_modules and package-lock.json, and run npm install. It helped me https://github.com/angular/angular-cli/issues/24262#issuecomment-1318410323

ghost avatar Nov 20 '22 12:11 ghost

@nseni: thanks for the suggestion. no change, unfortunately.

ianfmc avatar Nov 20 '22 17:11 ianfmc

@ianfmc, looks like one of the migrations didn’t run successfully.

Did you update using ng update?

alan-agius4 avatar Nov 20 '22 17:11 alan-agius4

@alan-agius4: appreciate the suggestion. I just ran an 'ng update' and then 'ng test' but there was no change. This is for a minimal project that I created yesterday, BTW. Please see above for the repository. Thanks!

ianfmc avatar Nov 20 '22 17:11 ianfmc

You need to run ng update prior of updating the dependencies.

If you already updated the dependencies, than you need to run ng update using the --migrate-only flag.

ng update @angular/cli --migrate-only --from=14 --to=15

alan-agius4 avatar Nov 20 '22 17:11 alan-agius4

That did it. I will try that on my original repository, too. Thanks!

ianfmc avatar Nov 20 '22 20:11 ianfmc

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.