question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

After Upgrade from Angular 14 to Angular 15, Tests No Longer Run

See original GitHub issue

Command

test

Is this a regression?

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

The previous version in which this bug was not present was

14.0.1

Description

I upgraded an Angular application from v14.0.1 to v15.0.2. The app builds without issue, but now when I run ng test, it does not find any tests. It doesn’t say that it doesn’t find any, but instead gives this output.

image

There are no errors in the browser console when this happens.

Minimal Reproduction

  1. Clone repo: https://github.com/mylifeandcode/workouttracker.git
  2. Get the code from the Angular15UpgradeTake2 branch
  3. Install packages
  4. Run ng test

Exception or Error

No error, just a Karma window that says ", randomized with seed " + the random number it used.

Your Environment

Angular CLI: 15.0.2
Node: 18.12.0
Package Manager: npm 8.3.0
OS: win32 x64

Angular: 15.0.2
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1500.2
@angular-devkit/build-angular   15.0.2
@angular-devkit/core            15.0.2
@angular-devkit/schematics      15.0.2
@angular/cdk                    13.3.3
@schematics/angular             15.0.2
rxjs                            6.6.7
typescript                      4.8.4

Anything else relevant?

Here is a link to the commit where the upgrade was performed: https://github.com/mylifeandcode/workouttracker/commit/f0702b93ef15ea0e2dd175e5acb2876fadd8470e

I understand that for new apps the test.ts file will no longer be generated. My app still has it, but the code that appears to be what would once get the list of spec files to process was removed during the upgrade migrations: (https://github.com/mylifeandcode/workouttracker/commit/f0702b93ef15ea0e2dd175e5acb2876fadd8470e#diff-a4f4ad1111064cc43a8f876c1be0bd5ba98f1b2b18f6fdfff6fec7057d515599). If this is the case, it would explain why no tests get run, but what are the correct modifications to re-enable them?

I followed the steps listed in the update guide but did not see any instructions related to this. I only learned of the changes related to test.ts after some searching.

My application was originally written in Angular 4 and I’ve upgraded it over the years as new versions are released – I’m not sure if that would have any bearing on this or not. This most recent upgrade was from v14.0.1 to v15.0.2.

Thank you for your help!

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
mylifeandcodecommented, Dec 8, 2022

Thanks again for the help @alan-agius4 . The work you’ve all done on Angular is much appreciated, I love this framework. 😃

0reactions
alan-agius4commented, Dec 8, 2022

The test.ts didn’t change much since the first releases.

https://github.com/angular/devkit/blob/v0.3.1/packages/schematics/angular/application/files/__sourcedir__/test.ts

Anyways glad to see that the recommended change works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Update Angular to v15
In v15, the component is not instantiated until after change detection runs. This change could affect tests that do not trigger change detection...
Read more >
Cannot run unit tests after upgrade from Angular 12 to 13 #8661
I know why this is happening - the CKEditor package imports one of its own dependencies using an import statement.
Read more >
Errors in unit tests with ng-bullet after upgrade to Angular 14
Jasmine tests have gotten faster over the years. ... the package it's not been actively maintained - hasn't been updated in 4 years....
Read more >
How To Update Angular CLI To Latest Version
Updating Angular CLI to the latest version (Angular v15) is pretty much simple if you are using Angular 9 or 10 version above....
Read more >
Angular >=13 | jest-preset-angular - GitHub Pages
Upgrade the project to Angular 13 following https://update.angular.io/ ... See example-app-v13 for an example with tests that run using ESM, and using ESM...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found