Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import firebase-functions/v2 #151

Closed
dima11221122 opened this issue May 20, 2022 · 4 comments · Fixed by #152
Closed

Cannot import firebase-functions/v2 #151

dima11221122 opened this issue May 20, 2022 · 4 comments · Fixed by #152
Assignees

Comments

@dima11221122
Copy link

Version info

firebase-functions-test: 2.1.0

firebase-functions: 3.21.2

firebase-admin: 10.2.0

Test case

import functions from 'firebase-functions-test';

Steps to reproduce

Expected behavior

No errors

Actual behavior

 Cannot find module 'firebase-functions/v2' from 'node_modules/firebase-functions-test/lib/cloudevent/mocks/pubsub/pubsub-on-message-published.js'

    Require stack:
      node_modules/firebase-functions-test/lib/cloudevent/mocks/pubsub/pubsub-on-message-published.js
      node_modules/firebase-functions-test/lib/cloudevent/mocks/partials.js
      node_modules/firebase-functions-test/lib/cloudevent/generate.js
      node_modules/firebase-functions-test/lib/v2.js
      node_modules/firebase-functions-test/lib/main.js
      node_modules/firebase-functions-test/lib/features.js
      node_modules/firebase-functions-test/lib/index.js
      src/sync/syncFunctions/utils/init-firestore.ts
      setupTests.ts

      at Resolver.resolveModule (node_modules/jest-resolve/build/resolver.js:324:11)
      at Object.<anonymous> (node_modules/firebase-functions-test/lib/cloudevent/mocks/pubsub/pubsub-on-message-published.js:4:14)
@TheIronDev
Copy link
Contributor

Thanks for opening up the issue!

I spun up a new project but was not able to reproduce this.

Do you have a repo I can look at?
If not, do you have an example of the function and test that you are running?

Thank you again!

@TheIronDev TheIronDev self-assigned this May 20, 2022
@ericallam
Copy link

I got this error message as well, when upgrading my project. I was importing firebase-functions-test from a jest setup file and getting the same error as @dima11221122. After upgrading my jest/ts-jest/ts-node dependencies to the latest versions this error went away.

@TheIronDev
Copy link
Contributor

@ericallam Oh man, I totally forgot about that!!

@dima11221122

If you're using jest < 28, you'll run into this issue.

Please try upgrading to jest@28 and let me know if you can still reproduce this.

More info:

I'll open a pr to include jest@28 as a peer dep to reduce this problem. Thank you for raising this!

TheIronDev added a commit that referenced this issue May 23, 2022
This commit adds a peerDep of >=jest@28.

jest@28 includes jestjs/jest#11961, which
supports `exports` in `package.json`.

Without this, jest users that use jest@27 or below will throw an error
when firebase-functions-test attempts to import several named exports.

Fixes #151
@dima11221122
Copy link
Author

Thank you guys for your help, after I upgraded to jest 28 the problem is gone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants