firebase-functions-test icon indicating copy to clipboard operation
firebase-functions-test copied to clipboard

Update Dependency to Firebase Functions v6

Open Nushio opened this issue 1 year ago • 3 comments
trafficstars

Version info

firebase-functions-test: 3.3.0

firebase-functions: 6.X

firebase-admin: 12.5.0

Test case

Upgrade Firebase Functions to 6.0 (Contains breaking change)

Tests won't pass anymore

Because the latest version changed the default entrypoint, imports of this library need to be rewritten to point to their v1 versions.

Nushio avatar Sep 23 '24 19:09 Nushio

This is the error I'm getting:

TypeError: Cannot read properties of undefined (reading 'userRecordConstructor')
      at Object.makeUserRecord (node_modules/firebase-functions-test/lib/providers/auth.js:30:38)
      at mockCustomer (test/helpers/customers.ts:10:47)
      at Context.<anonymous> (test/purchases/handlers/savePurchase.spec.ts:11:38)
      at processImmediate (node:internal/timers:478:21)
      at process.callbackTrampoline (node:internal/async_hooks:130:17)

When i try to create a user:

  const userRecord: UserRecord = testEnv.auth.makeUserRecord({
    email: customer.email,
    displayName: customer.displayName,
    uid: userUid,
  });

brunapereira avatar Sep 27 '24 22:09 brunapereira

Oh no, we are migrating Firebase Functions to 6.0 and our cloud functions to V2 and this is breaking our tests

unxavi avatar Sep 29 '24 21:09 unxavi

I created this PR that maybe should fix it: https://github.com/firebase/firebase-functions-test/pull/243

I don't exactly know what I'm doing, but I had to make similar changes in my own repo, so maybe it's this simple.

EnduringBeta avatar Oct 02 '24 19:10 EnduringBeta

It's been a couple of months with no response here. There's even a PR listed. Is there anyone working on this project or should we consider it abandoned?

Nushio avatar Nov 12 '24 17:11 Nushio

@EnduringBeta would you be willing to publish your fork under a namespace so that people can use that in the meantime?

AverageHelper avatar Nov 13 '24 06:11 AverageHelper

@EnduringBeta would you be willing to publish your fork under a namespace so that people can use that in the meantime?

Sorry for the delay. I haven't done that before for this purpose.

I merged my PR into my own fork, so it's on master here: https://github.com/EnduringBeta/firebase-functions-test

Is that what's needed, and then y'all update your pubspec.yaml to point to this repo and branch?

EnduringBeta avatar Nov 25 '24 19:11 EnduringBeta

@EnduringBeta Actually I was hoping for an NPM package :sweat_smile: or maybe figuring some way to have the lib directory published in the git repo, since package.json references that directory. That way, people could either point their package.json at your repo URL directly, or run npm install @enduringbeta@firebase-functions-test to get the built version from NPM.

I imagine adding a namespace to the package name in package.json (e.g. @enduringbeta@firebase-functions-test) and running ./scripts/publish.sh would do the trick.

AverageHelper avatar Dec 01 '24 02:12 AverageHelper

I think pubspec.yaml is a Dart thing, so wouldn't work for a Node project..

AverageHelper avatar Dec 01 '24 02:12 AverageHelper

@EnduringBeta Actually I was hoping for an NPM package 😅 or maybe figuring some way to have the lib directory published in the git repo, since package.json references that directory. That way, people could either point their package.json at your repo URL directly, or run npm install @enduringbeta@firebase-functions-test to get the built version from NPM.

I imagine adding a namespace to the package name in package.json (e.g. @enduringbeta@firebase-functions-test) and running ./scripts/publish.sh would do the trick.

Thanks for this guidance and your patience. I will do my best to accomplish this soon, but it's a busy time for me and I haven't done this before.

And yeah, I use this in combo with my Flutter/Dart project, so I lost sight of this needing to be for NPM/package.json.

EnduringBeta avatar Dec 10 '24 16:12 EnduringBeta

For anyone that still needs this, I used @EnduringBeta 's branch and added the 'lib' folder to it so that it can be used.

I use this line on my package.json:

"firebase-functions-test": "github:Nushio/firebase-functions-test",

I mean to take no credit for this, just putting it out there so others can continue testing the functions before deploying :)

Nushio avatar Dec 11 '24 18:12 Nushio

I just heard from our Google Cloud Support contact. They are working on merging the PRs. They just need to resolve some legalese.

@EnduringBeta you may have to sign their standard contributor license agreements first, once that's setup ☺️

IchordeDionysos avatar Dec 11 '24 23:12 IchordeDionysos

I just heard from our Google Cloud Support contact. They are working on merging the PRs. They just need to resolve some legalese.

@EnduringBeta you may have to sign their standard contributor license agreements first, once that's setup ☺️

I believe I've signed one of those for Google before. I'm not sure if there are multiple for different products.

Thanks for the update. I'll await notice here for any further steps.

EnduringBeta avatar Dec 12 '24 17:12 EnduringBeta