Skip to content

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

Open
@Chralu

Description

@Chralu

Describe your environment

  • Operating System version: MacOS 12.1
  • Browser version: Firefox 97.0.1
  • Firebase SDK version: @firebase/rules-unit-testing 2.0.1
  • Firebase Product: rules-unit-testing, functions

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 :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions