firebase / firebase-functions-test

MIT License
232 stars 48 forks source link

Support rawRequest in callable context #41

Closed JFGHT closed 4 years ago

JFGHT commented 5 years ago

As you can see here https://github.com/firebase/firebase-functions/blob/master/src/providers/https.ts, there's rawRequest: Request; missing from firebase-functions-test's CallableContextOptions.

It is not possible to wrap the function with a rawRequest under the context option because _checkOptionValidity doesn't pass.

Steps to reproduce

myFunctions = require('../src/index');
const wrapped = testEnv.wrap(myFunctions.bankAccountChange);
const onCallObjects: [any, ContextOptions] = [
  {},
  {
    auth: { uid: '32344', token: { email: 'blab' } },
    // @ts-ignore
    rawRequest: { headers: { origin: 'url' } },
  },
];

await expect(wrapped(...onCallObjects)).rejects.toThrow('There was an error reading the investor data.');

Actual behavior

Throws error: Options object {"auth":{"uid":"32344","token":{"email":"blab"}},"rawRequest":{"headers":{"origin":"url"}}} has invalid key "rawRequest"