Skip to content

Feature request: Stop entire test suite execution on beforeAll failure #1533

@juliemr

Description

@juliemr

This is somewhat related to issue #577, but different because it deals with beforeAll instead of beforeEach. In many situations, I imagine that a failure in beforeAll means that there's no useful information to be gained from continuing the test. It would be nice to immediately fail without trying to run each of the specs after that.

Expected Behavior

describe('bad setup', function() {
  beforeAll(function() {
    throw new Error('error from beforeAll');
  });

  it('test 1', function() {
    expect(1).toEqual(11);
  });
});

Expected behavior - output:
Suite error: bad setup
Message:
Error: error from beforeAll

Current Behavior

Output tries to run all tests:
Failures:

  1. bad setup test 1
    Message:
    Expected 1 to equal 11.
    Stack:
    ...

  2. bad setup test 2
    Message:
    Expected 2 to equal 22.
    Stack:
    ...

Suite error: bad error
Message:
Error: error from beforeAll

Suite that reproduces the behavior (for bugs)

describe('bad setup', function() {
  beforeAll(function() {
    throw new Error('error from beforeAll');
  });

  it('test 1', function() {
    expect(1).toEqual(11);
  });
});

Your Environment

Jasmine 3.1. I believe this behavior is the same in all environments. I have tried both with and without stopSpecOnExpectationFailure

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions