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

AssertionError #133

Open
boneskull opened this issue Apr 22, 2015 · 0 comments
Open

AssertionError #133

boneskull opened this issue Apr 22, 2015 · 0 comments

Comments

@boneskull
Copy link

In mochajs/mocha#1635, we are considering adding support for suite continuation if a hook throws an AssertionError.

Because expect.js doesn't actually throw an AssertionError upon failure, this feature will simply not work with expect.js.

Would like to start a discussion about expect.js throwing AssertionErrors, much like Chai or should. I imagine:

  • in a server context, use require('assert').AssertionError

  • in a client context, the assertion library must define a global AssertionError. Example:

    var AssertionError = function(message, actual, expected) {
      this.message = message;
      this.actual = actual;
      this.expected = expected;
      this.showDiff = true;
    };
    // or whatever you need to do for old browser support
    AssertionError.prototype = Object.create(Error.prototype);
    AssertionError.prototype.name = 'AssertionError';
    AssertionError.prototype.constructor = AssertionError;

Would this break backwards compatibility? Any user checks of err instanceof Error should still work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant