Skip to content

Signals : effect() is not triggered for unit tests #50466

@MGX-CODING

Description

@MGX-CODING

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

No

Description

When unit testing an effect, it seems that it cannot be triggered. I would expect my effect to trigger so that I can test its content.

Here is a ZIP file of a simple project to test it : unzip it, run npm install, then npx ng test.

Main files are app.service.ts and app.service.spec.ts, code is fairly simple you'll see.

test.zip

Please provide a link to a minimal reproduction of the bug

Please see above

Please provide the exception or error you saw

No exception, just no effect trigger

Please provide the environment you discovered this bug in (run ng version)

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


Angular CLI: 16.0.2
Node: 18.10.0
Package Manager: npm 8.19.2
OS: linux x64

Angular: 16.0.3
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1600.2
@angular-devkit/build-angular   16.0.2
@angular-devkit/core            16.0.2
@angular-devkit/schematics      16.0.2
@angular/cli                    16.0.2
@schematics/angular             16.0.2
rxjs                            7.8.1
typescript                      5.0.4

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtimearea: testingIssues related to Angular testing features, such as TestBedcore: reactivityWork related to fine-grained reactivity in the core frameworkcross-cutting: signals

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions