Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More descriptive beforeEach/afterEach messages #1230

Closed
YourDeveloperFriend opened this issue May 28, 2014 · 1 comment · Fixed by #1447 or gluckgames/pixi-packer#17
Closed

More descriptive beforeEach/afterEach messages #1230

YourDeveloperFriend opened this issue May 28, 2014 · 1 comment · Fixed by #1447 or gluckgames/pixi-packer#17
Labels
type: feature enhancement proposal

Comments

@YourDeveloperFriend
Copy link

I would like a failure in an beforeEach or afterEach to output which test it ran afterwards. For example:

describe('My Object', function() {
  var myObj;
  beforeEach(function() {
    myObj = new MyObject();
  });
  afterEach(function() {
    myObj.ensureClean(); // May throw an error
  });
  it('should do something', function() {
    myObj.doSomething();
  });
  it('should do something else', function() {
    myObj.doSomethingElse();
  });
});

If ensureClean throws an error, I don't know which test corrupted the object, since the error message gives me something generic:

  1) My Object "after each" hook:
     Error: The object was not clean
     <stack>

It would be great if the message said something like this:

  1) My Object "after each" hook after "should do something"
     Error: The object was not clean
     <stack>

I frequently put global checks into the afterEach, maybe that's not the right way to go about this?

@boneskull
Copy link
Member

I also have this issue. Sometimes I'm forced to put assertions into beforeEach() due to the way angular-mocks builds injectors. It would be helpful to see which test caused the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature enhancement proposal
Projects
None yet
2 participants