title: how to assert in my tests that a Chai assertion will fail (Error vs. AssertionError)
body: <p>I am puzzled by the inheritance relationship of <code>Error</code> and <code>AssertionError</code> and how that works with <code>assert.throws</code>.</p>
  
  <p>In my test code I have:</p>
  
  <pre><code>// @flow
  ...
  import {assert} from 'chai';
  import {AssertionError}  from 'assertion-error';
  
  describe('foo', function() {
      it('boo', function() {
          assert.throws( ()=&gt;{throw new Error()}
                         , AssertionError); //a 
          assert.throws( ()=&gt;{throw new AssertionError()}
                         , Error);          // b
          assert.throws( ()=&gt;{assert.isTrue(false);}
                         , Error);          // c
          assert.throws( ()=&gt;{assert.isTrue(false);}
                         , AssertionError); // d
      });
  });
  </code></pre>
  
  <p><em>all</em> of the above <code>assert.throws</code> statements succeed. I was expecting some of them to succeed and some to fail.
  Specifically, given that AssertionError has Error as its prototype I was expecting <code>a</code> to fail as a stricter type is demanded (<code>AssertionError</code>) than that thrown (<code>Error</code>). Instead it succeeded along with the rest. What gives?</p>
  
  <p>The packages I am using are:</p>
  
  <pre><code>chai@4.1.2
  mocha@3.5.3
  </code></pre>
  
  <h1>update</h1>
  
  <p>Based on <a href="https://stackoverflow.com/a/46458047/274677">this answer</a> I confirm that if, instead of:</p>
  
  <pre><code>import {assert} from 'chai';
  import {AssertionError}  from 'assertion-error';
  </code></pre>
  
  <p>&hellip; I do:</p>
  
  <pre><code>const assert = require('chai').assert;
  const AssertionError = require('assertion-error');
  </code></pre>
  
  <p>&hellip; then the results are as expected.</p>