firebase / firebase-js-sdk

Firebase Javascript SDK
https://firebase.google.com/docs/web/setup
Other
4.82k stars 884 forks source link

FR: `rules-unit-testing v2` expose `RulesTestContext.functions()` #6059

Open Chralu opened 2 years ago

Chralu commented 2 years ago

Describe your environment

Describe the problem

I would like to write automated e2e tests to validate my cloud functions using Firebase emulators.

With @firebase/rules-unit-testing v1, I could easily get a Functions context with fake authentication :

    const app = initializeTestApp({ 
        projectId: MY_PROJECT_ID, 
        auth: { uid: "my_uid"}
    })
    app.functions().useEmulator("localhost", 5001)
    const funcToTest = app.functions().httpsCallable("myFunctionToTest")
    // Do some tests

With @firebase/rules-unit-testing v2, there is no way to do the same :

const testEnv = await initializeTestEnvironment({
    projectId: MY_PROJECT_ID,
})

const authenticatedContext = testEnv.authenticatedContext("my_uid")

//There is no `authenticatedContext.functions()` accessor

This seems extremely problematic to me, since it makes cloud functions e2e testing a real pain.

I would be happy to talk about this with you :)

djbb7 commented 1 year ago

Are there any updates on this?