Skip to content

afterAll inside a describe hides errors #6692

@galenmaly

Description

@galenmaly

🐛 Bug Report

Errors thrown in afterAll inside a describe can cause a test suite to fail silently.

This bug was previously reported under #3266 and fixed under #5884 - but the fix addresses errors in an afterAll at the top level, not inside a describe.

To Reproduce

describe('broken afterAll', () => {
  afterAll(() => {
    expect(1).toEqual(2);
  });
  it('should pass regardless.', () => {});
});

Expected behavior

The test suite should fail, like it does if the error were thrown in a top-level afterAll.

Link to repl or repo (highly encouraged)

https://repl.it/HAYG/1 (same repl as #3266 - thanks @gdborton)

As of writing repl.it is only running jest 22.1.2 whereas the fix for #3266 was released in 23.0.0. However the issue is present in the latest version of 23.4.1.

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: macOS High Sierra 10.13.6
    CPU: x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
  Binaries:
    Node: 10.6.0 - /usr/local/bin/node
    npm: 6.1.0 - /usr/local/bin/npm
  npmPackages:
    jest: 23.4.1 => 23.4.1 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions