vendredi 2 septembre 2016

Possibile to stop test of first expectation failure?

On a scenario like this, my test it will throw an exception and fail when comparing person.name with john, even it have failed on the previous expect``:

describe('demo suite', function () {
  it('older test', function (done) { /* some code */});
  it('old test', function (done) { /* some code */});

  it('new test', function (done) {

    //should be an object, but let's assume that for some Exception/Error on function returns a null
    var person = getPerson(); 

    expect(person).not.toBeNull();
    expect(person.name).not.toBeNull(); // if person == null will not stop here and throw an exception later
    expect(person.name).toBe('john');

    done();

  });

  it('newer test', function (done) { /* some code */});

});

I'm able to configure stopSpecOnExpectationFailure which will stop all test suite. Not really what I'm looking for.

By the given scenario, I wonder if it's possible to expect most of tests to run (even beforeAll(), before(), afterAll(), after()) and receive a failed test ONLY for new test and not a Exception.

Aucun commentaire:

Enregistrer un commentaire