GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Unit test fails with zone application and vitest · Issue #32555 · angular/angular-cli

Unit test fails with zone application and vitest #32555

New issue
Copy link
New issue
Copy link
Closed
Bug
Closed
Unit test fails with zone application and vitest#32555
Bug
Copy link
Labels
angular/build:unit-testarea: @angular/buildneeds: investigationRequires some digging to determine if action is neededRequires some digging to determine if action is neededtype: bug/fix

Description

@chabb
chabb
opened on Feb 24, 2026
Issue body actions

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

No response

Description

Hello Angular Team,

ng version: 21.1.5

Unit tests fail in a very weird way for projects that use the zone
Some fields of the components are simply not assigned, which causes a failure when the view is rendered
Strangely, this happens when multiples components consumes the same import ( this typically happens with exported constants )

You can find a simple repro below.

https://stackblitz.com/edit/angular-v21-starter-w7aywxrw?file=README.md

If I remove the polyfill, it passes ( I've noticed that the generated javascript is different )

Please not that we cannot migrate all our apps/libs to zoneless in one shot ( we are in an enterprise setup with a lot of libs ),
so it's really an issue that prevent us for migrating to ng21

Thanks for considering this issue,

FC

Minimal Reproduction

https://stackblitz.com/edit/angular-v21-starter-w7aywxrw?file=README.md

Exception or Error

Some fields of the component is undefined, which causes failure when the template is rendered during the test.



TypeError: Cannot read properties of undefined (reading 'A')

Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI       : 21.1.5
Angular           : 21.1.5
Node.js           : 20.19.1
Package Manager   : npm 10.8.2
Operating System  : linux x64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build            │ 21.1.5            │ ^21.1.5           │
│ @angular/cli              │ 21.1.5            │ ^21.1.5           │
│ @angular/common           │ 21.1.5            │ ^21.1.5           │
│ @angular/compiler         │ 21.1.5            │ ^21.1.5           │
│ @angular/compiler-cli     │ 21.1.5            │ ^21.1.5           │
│ @angular/core             │ 21.1.5            │ ^21.1.5           │
│ @angular/forms            │ 21.1.5            │ ^21.1.5           │
│ @angular/platform-browser │ 21.1.5            │ ^21.1.5           │
│ @angular/router           │ 21.1.5            │ ^21.1.5           │
│ rxjs                      │ 7.8.2             │ ~7.8.0            │
│ typescript                │ 5.9.3             │ ~5.9.2            │
│ vitest                    │ 4.0.18            │ ^4.0.8            │
│ zone.js                   │ 0.15.1            │ ~0.15.0           │
└───────────────────────────┴───────────────────┴──────────────────

Anything else relevant?

Removing the polyfill fixes it.

Tweaking the tsconfig.spec.json to use node module system fixes it ( see in the stackblitz )

Reacted by Dany Marques, MoritzHulliger, crvx, Maciej Niedzielski and Edminsson
Reacted by Maciej Niedzielski and Halanson

Activity

  1. JeanMeche commented on Feb 24, 2026

    @JeanMeche
    JeanMeche
    on Feb 24, 2026
    Member
    More actions

    I chatted with @chabb.

    There is a race condition at play here. Here is what we found:

    • dropping all async/await the test passes (code isn't downleveled anymore)
    • hooking up the debugger, the test passes correctly (even with async/await
    • test run fine in browser mode
    Reacted by Dany Marques
  2. alan-agius4
    added
    needs: investigationRequires some digging to determine if action is neededRequires some digging to determine if action is needed
    area: @angular/build
    angular/build:unit-test
    on Feb 24, 2026
  3. alan-agius4
    added the
    Enhancement
    issue type on Feb 24, 2026
  4. alan-agius4
    changed the issue type from
    Enhancement
    to
    Bug
    on Feb 24, 2026
  5. alan-agius4
    added
    type: bug/fix
    on Feb 24, 2026
  6. chabb commented on Feb 24, 2026

    @chabb
    chabb
    on Feb 24, 2026
    Author
    More actions

    This looks like some kind of race condition, you can see the generate JS in the image below.
    I've put a breakpoint, and it turns out than the TEST variable ( which is assigned to a field of the component and points to an export of a module ) is actually undefined. But the module itself has the right value, so I guess it has been defined at a later time
    Image

    Reacted by Dany Marques
  7. clydin commented on Aug 13, 2026

    @clydin
    clydin
    on Aug 13, 2026
    Member
    More actions

    Resolved via #33729

  8. clydin
    closed this as completedon Aug 13, 2026
  9. angular-automatic-lock-bot commented on Oct 19, 2026

    @angular-automatic-lock-bot
    angular-automatic-lock-botBot
    on Oct 19, 2026
    More actions

    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.

  10. angular-automatic-lock-bot
    locked and limited conversation to collaborators on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    angular/build:unit-testarea: @angular/buildneeds: investigationRequires some digging to determine if action is neededRequires some digging to determine if action is neededtype: bug/fix

    Type

    Bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.