Skip to content

[Bug]: Unhandled AggregateErrors not displayed properly #15668

Open
@OliverJAsh

Description

@OliverJAsh

Version

29.7.0

Steps to reproduce

  1. Clone https://github.com/OliverJAsh/jest-aggregate-error-after-all
  2. npm install
  3. npm run test

Expected behavior

The AggregateError details are displayed.

Actual behavior

The AggregateError details are not displayed.

$ npm run test

> test
> jest

 FAIL  ./test.js


  ● Test suite failed to run

    AggregateError:

      4 |
      5 | // Example
    > 6 | afterAll(() => Promise.reject(new AggregateError(errors)));
        |                               ^
      7 |
      8 | it("works", () => {
      9 |   expect(1).toEqual(1);

      at Object.<anonymous> (test.js:6:31)

Test Suites: 1 failed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        0.147 s, estimated 1 s
Ran all test suites.

Additional context

Related but not the same: #14704. #15346 fixed this in toThrowMatchers. However, the issue I am describing is different. This is about the appearance of unhandled errors rather than toThrowMatchers errors.


I believe the AggregateError is converted to a string at this step, via getErrorStack:

unhandledErrors: unhandledErrors.map(_getError).map(getErrorStack),

Environment

I don't think this is relevant but in any case:

  System:
    OS: macOS 15.5
    CPU: (10) arm64 Apple M1 Pro
  Binaries:
    Node: 22.14.0 - /nix/store/g5bv4gi6p7ryhs2hbaryxs6ivsxa6lqc-nodejs-22.14.0/bin/node
    npm: 10.9.2 - /nix/store/g5bv4gi6p7ryhs2hbaryxs6ivsxa6lqc-nodejs-22.14.0/bin/npm
  npmPackages:
    jest: ^30.0.0 => 30.0.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions