I have a test suite with an instance of firebase-server module, invoked both in the test suite and another separate function. 

That is so I can test various test cases with mock values inside my firebase instance.

In my test suite I perform various tests, and they all work as intended until I get to the point where I am testing Firebase promise: 

```
Firebase.database().ref('userData').once('value').then((data) => {

    // --- USER ID VALIDATION ---//
    if (!userIds[USER_ID]) {
      throw(`Invalid User ID: ${USER_ID}`);
    }
    updates[`${USER_ID}/sessions/${newSessionKey}`] = event.session;

    // --- UPDATE DATABASE ---//
    Firebase.database().ref().update(updates)
      .then(() => context.succeed('Database Write Successful.'))
      .catch(error => context.fail(`Database Write Error: ${error}`));
})
.catch(error => context.fail(`Database Access Error: ${error}`));

```

by mocking the database content to make my call to my lambda function fail:

```
it( 'should fail invocation with invalid user Id: ', function( done ) {

  var context = {
    succeed: function() {
      done( new Error( 'never context.succeed' ) );
    },
    fail: function( errorMessage ) {
      expect( errorMessage ).to.have.string("Invalid User ID");
      done( );
    }
  }
  dbReset();// resetting database state to valid format
  Firebase.database().ref('userData').set({
    "InvalidFakeUserID" : {
      "apiHits" : 100
    }
  })
  myLambda( event, context );
});

```

Now, I understand that the lambda function is returning an error, but I can't figure how to handle the error assertion on the test side. When I am trying to expect a particular string it passes the test every time, no matter what the string I am expecting. If I expect an error instead:

```
fail: function( errorMessage ) {
      expect( errorMessage ).be.an('error');
      done( );
}

```

it also triggers an error: 

`(node:12144) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): AssertionError: expected 'Opearlo Analytics --- Database Access Error: Error: Invalid Voice App Name: fakeNameNotPresentOnDB' to be an error`

Anyone that can point me in the right direction?