code: function expectRejection (promise, expectedReason) {
      return promise.then(
          () => fail('Expected promise to be rejected'),
          reason => {
              if (expectedReason instanceof Error) {
                  expect(reason instanceof expectedReason.constructor).toBeTruthy();
                  expect(reason.message).toContain(expectedReason.message);
              } else if (typeof expectedReason === 'function') {
                  expect(expectedReason(reason)).toBeTruthy();
              } else if (expectedReason !== undefined) {
                  expect(reason).toBe(expectedReason);
              } else {
                  expect().nothing();
              }
          });
  }
docs: Expect promise to get rejected with a reason matching expectedReason