soumak77 / firebase-mock

Firebase mock library for writing unit tests
https://soumak77.github.io/firebase-mock
350 stars 96 forks source link

firebase.auth().createUser fails silently when it has `await` #141

Open mis8680 opened 5 years ago

mis8680 commented 5 years ago

I found some weird issue with auth() mock object. Here is my code:

const mocksdk = firebasemock.MockFirebaseSdk(null, function () {
    return mockauth;
}, function () {
    return mockfirestore;
});

const seedTestData = proxyquire('../seedData', {
    'firebase-admin': mocksdk
});
const userDoc = await admin.auth().createUser({
            uid: `user_${i}`,
            email: emailAddress,
            emailVerified: true,
            password: 'password',
            displayName: `${firstName} ${lastName}`,
            disabled: false
        });

The admin.auth().createUser fails without any error. but If I update the code with this, It works.

admin.auth().createUser({
            uid: `user_${i}`,
            email: emailAddress,
            emailVerified: true,
            password: 'password',
            displayName: `${firstName} ${lastName}`,
            disabled: false
        }).then((user) => {
            console.log("created user: ", user);
        });

I wonder If firebase-mock support async/await?! I am using mocha to test.

jorgeeferreyra commented 4 years ago

I have the same issue D:

lgan1989 commented 4 years ago

mockauth.autoFlush(1); should do the trick.