firebase / firebase/firebase-js-sdk
FR: `rules-unit-testing v2` expose `RulesTestContext.functions()`
- Dominant language
- TypeScript
- Stars
- 5.1k
- Forks
- 1k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 37
Description
### 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 :
```ts
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 :
```ts
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 :)
Contributor guide
Assessment
This issue has not been assessed yet.