firebase / firebase-functions-test

MIT License
232 stars 48 forks source link

feat: `wrap` method now accepts `resource` as override in Context object. #61

Closed dackers86 closed 4 years ago

dackers86 commented 4 years ago

Description

As part of trying to test the extensions/firestore-bigquery-export module. We need to introduce the ability to set the resource key values (the types already support this, just this change is missing). Specifically, this line will fail when using the function wrap helper with cannot read property 'name' of undefined. This change allows us to specify the resource values needed for the wrapped cloud function trigger.

Code sample

const wrapped = functionsTest.wrap(require("../src/index").fsexportbigquery);
wrapped(docChange, {
  eventId: "test",
  resource: {
    name: "test",
  },
});
Salakar commented 4 years ago

cc @laurenzlong for review - thanks!

dackers86 commented 4 years ago

Could you also add "resource" to the EventContextOptions type? https://github.com/firebase/firebase-functions-test/blob/master/src/main.ts#L28

@laurenzlong Added resource types. Thanks

laurenzlong commented 4 years ago

@dackers86 this has been published in v0.2.1